1、报错信息
1.1idea中报错信息
Resolved [org.springframework.web.bind.MissingServletRequestParameterException: Required request parameter 'id' for method parameter type Integer is not present]
1.2网页报错信息
Whitelabel Error Page
This application has no explicit mapping for /error, so you are seeing this as a fallback.
Sun Nov 14 15:36:12 CST 2021
There was an unexpected error (type=Bad Request, status=400).
Required request parameter 'id' for method parameter type Integer is not present
org.springframework.web.bind.MissingServletRequestParameterException: Required request parameter 'id' for method parameter type Integer is not present
2、报错原因
2.1Controller里面代码如下,需要传参
@GetMapping("/getbook")
@ResponseBody
public Book getBook(@RequestParam("id") Integer id){
Book bookById = bookService.getBookById(id);
return b