@PathVariable,@RequestParam,@RequestBody

1.针对一些非必填的参数,可以使用required关键字来标识,同时必须设置默认值defaultValue,如getOrder方法中对price参数的获取:
@RequestParam(value = "price",required = false,defaultValue = "0") Integer price
2.参数可以不配注解直接与Entity类绑定,但不支持json格式,只支持form-data和x-www.form-urlencoded格式
@PostMapping("/order/add")
public String addOrder(Order order){
网友评论