Springboot下的springmvc和之前的springmvc使用是完全一致的
1.@Controller
即爲spring mvc的註解,處理http請求
2.@RestController
Spring4後新增註解:
是@Controller註解功能的增強
是@Controller和@ResponseBody的組合註解
如果一個Controller類添加了@RestController,那麼該Controller類下的所有方法都相當於添加了@ResponseBody註解
用於返回字符串或json數據
3.@RequestMapping
支持Get請求,也支持Post請求
4.@GetMapping
RequestMapping和Get請求方法的組合
只支持Get請求
Get主要用於查詢數據
和@RequestMapping(value = "/boot/updateStudent",method = {RequestMethod.GET})效果是一致的
5.@PostMapping
RequestMapping和Post請求方法的組合
只支持Post請求
Post通常用於新增數據
和@RequestMapping(value = "/boot/updateStudent",method = {RequestMethod.POST})效果是一致的
6.@PutMapping
RequestMapping和Put請求方法的組合
只支持put請求
Put通常用於修改數據
7.@DeleteMapping
RequestMapping和Delete請求方法的組合
通常用於刪除數據