The content of this article is about the solution to the problem that Spring MVC cannot obtain the parameter value normally (with code). It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you. .
I recently encountered a very strange problem during development. When using the Spring MVC framework in tomcat8, the method parameters in the Controller could not obtain the corresponding values normally. It was solved by changing the tomcat version to 7.0.
Record the following solution process, first the above picture:
Using this parameter passing method, the value of the parameter can indeed be received, but the method of receiving parameters and the method of passing parameters have become complicated. I copied this project home from the company and continued to write it. When I was at the company, everything was debugging fine, but when I returned home, it didn’t work. I was puzzled. I had not changed the same code, so why did something go wrong when I got home? ? Since the codes are the same but the running results are different, it only means that the running environment has changed. So where exactly is the environment different? When this kind of problem occurs, first consider the structure of the database. However, the database version of the home computer is the same as the company computer, and the data is copied directly from the company, so the database is directly ruled out, not to mention that it is received in the Controller. Without the parameters and the step of accessing the database, it is even less likely to be related to the database, so the cause of the database can be ruled out directly. Since the project is built by maven, the relevant jar packages are automatically downloaded by maven, so I wonder if there is a problem with the jar packages that maven automatically downloads. Then delete all the jar packages in the local warehouse and let maven start again. I downloaded it and repeated it several times, but the problem still existed. I had no choice but to temporarily rule out the cause of maven. In the end, I couldn't think of any other reasons, so I began to doubt the cause of tomcat. The company's tomcat is version 7.0, and the tomcat at home is version 8.0. Although the two tomcat versions are inconsistent, I didn't subconsciously think that it must be the tomcat version. After all, I subconsciously think that 8.0 must be an upgrade of functions after 7.0. Although I thought this way, I still went to the test with the mentality of being a dead horse and a live doctor. I downloaded the 7.0 version of the compressed package from the tomcat official website, then configured the corresponding environment and called it with postman. The result was so unexpected. Did you get the parameter value? ! ! ! Is it really because of the tomcat version? This feels too boring. . . . It seems that blindly pursuing higher versions is not a good thing [Related recommendations:Java Tutorial]
The above is the detailed content of Solution to the problem that Spring MVC cannot obtain the value of parameters normally (with code). For more information, please follow other related articles on the PHP Chinese website!