报错一:
org.springframework.web.bind.MissingPathVariableException: Required URI template variable ‘id’ for method parameter type Long is not present
原因:
@GetMapping("/getInfo") public BaseResponse getInfo(@PathVariable("id") Long id){ return xxx; }
postman -> http://ip:prot/xxxxx/getInfo?id=1
解决方法有两种:
一、@PathVariable 改为 @RequestParam 即可
二、@GetMapping(“/getInfo”) 改为 @GetMapping(“/getIn/{id}”)
postman -> http://ip:port/xxxxx/getInfo/1
报错二:
org.springframework.web.bind.MissingServletRequestParameterException: Required request parameter ‘ids’ for method parameter type Long[] is not present
原因:
@DeleteMapping("/delete")
public BaseResponse delete(@RequestParam("ids") Long[] ids) {
return xxx;
}
解决方法:
@RequestParam 改为 @PathVariable ,@DeleteMapping(“/delete”) 改为 @DeleteMapping(“/delete/{ids}”)
postman -> http://ip:port/xxxxx/delete/122222,3333334
postman -> http://ip:port/xxxxx/delete/166666