如果传的参数是@RequestBody ,多参或者传对象的情况下使用@PostMapping注解:
@PostMapping("/getOrderList")
public List<Object> getList(@RequestBody List<Object> orderList) {}
无参,@RequestParam 和@PathVaiable的情况下使用GetMapping:
@gettMapping("/test")
public ModelAndView test16(@RequestParam("id")Long id){}
@gettMapping("/test/{id}")
public ModelAndView (@PathVaiable("name") Long id){}
个人心得:
1.当方法需要对数据库进行数据修改或增加数据时使用PostMapping
2.当方法仅从数据库中获取信息时使用GetMapping
3.当方法需要对数据库进行删除操作是使用DeleteMapping