报错:java.lang.IllegalArgumentException: Unknown return value type: java.lang.Integer
Solution:
Add the annotation @ResponseBody to the controller.
- The function of @ResponseBody annotation is usually to convert the controller's method parameters into JSON format for data return, and write it in the body area of the response object.
code show as below:
@RequestMapping("/LoginUser")
@ResponseBody
public User LoginUser(User user){
return user;
}
Then the data displayed on the page is displayed in JSON format , such as:
{"name":"张三","age":18}