Spring boot请求参数
GET请求:
1.restful风格:
@GetMapping("/order/detail") public BaseOutput omsQueryDetail(@RequestParam("orderId") String id) { }
2.resultful风格:
@GetMapping("/order/detail/{orderId}") public BaseOutput omsQueryDetail(@PathVariable String orderId) { }
POST请求:
@PostMapping("/order/detail") public BaseOutput orderDetail(@RequestBody OrderDetailReq req) { }
一些情况:
1.使用@RequestParam,参数不一定存在时
@RequestParam(name="id",required=false)
@RequestParam(name="id",required=false,defaultValue="0")