SpringBoot使用总结
SpringBoot 在 Controller 中常用注解
@RestController 相当于@Controller+@ResponseBody 注解 如果使用@RestController 注解 Controller 中的方法无法返回页面,相当于在方法上面自 动 加 了@ResponseBody 注 解 , 所 以 没 办 法 跳 转 并 传 输 数 据 到 另 一 个 页 面 , 所以 InternalResourceViewResolver 也不起作用,返回的内容就是 Return 里的内容。
@Controller 可以跳转到另一个界面
@GetMapping 注解是@RequestMapping(method=RequestMethod.GET)的缩写。
@PostMapping 注解是@RequestMapping(method= RequestMethod.POST)的缩写。
@PutMapping 注解是@RequestMapping(method=RequestMethod.PUT)的缩写。
@DeleteMapping 注解是@RequestMapping(method=RequestMethod.DELETE)的缩写。
在SpringBoot中使用Servlet
1 |
|
在启动上加入 @ServletComponentScan 在 Spring Boot 启动时会扫描 @WebServlet 注解并注册
- 本文作者: GermMC
- 本文链接: http://blog.germmc.com/2020/05/15/SpringBoot使用总结/
- 版权声明: 本博客所有文章除特别声明外,均采用 MIT 许可协议。转载请注明出处!