[Turn] Summary of Http400 Bad Request encountered in SpringMVC

In building the SpringMVC environment, I encountered many Bad Request connections in use. Let's summarize it below.

1. The parameter type is wrong, for example, the attribute of the background entity class is int, but the parameter passed is a string

2. Because of my carelessness, I wanted to get a json string through Ajax, but the background method did not add the @RequestBody annotation before the return value type

3. The parameter passed is the date. Spring MVC does not know what format to convert to Date type. The solution is to add the @DateTimeFormat(pattern="yyyy-MM-dd") annotation to the date attribute of the entity class.

4. The problem I just encountered, after investigating for a long time, I finally know the reason. There is an attribute of type int in the entity class, but when the front-end parameter is passed, it looks like this "age=", which does not give an accurate number. (age=18), so Spring cannot correctly assign values ​​when assigning values ​​to int properties

 

At present, I have encountered these reasons for the connection of Bad Request. You are welcome to add, and I will continue to update

 

Reprinted from: http://blog.csdn.net/c5906343/article/details/26482975 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326456307&siteId=291194637