The problem description of the Chinese parameter of the Spring MVC controller parsing get mode is garbled
In the work of using the sudden appearance from get to get the Chinese parameters garbled (the newly installed machine, Tomcat re-download and configuration), looked for a half-day finally found a solution.
Why is it garbled?
Spring MVC is based on a servlet, and the URL for get comes in before the HTTP request arrives at the servlet resolution, which is urldecode by Tomcat first. Tomcat's default URL decoding result for Get mode is iso-8859-1 instead of what I think of as UTF-8.
Solution Solutions
The solution is also simple, except for the usual transcoding filter,jsp configured in the Project Web. Xml with code files, the key point is to configure Connector urieconding= in Server.xml in Tomcat's conf directory. The "UTF-8" property can be.
Description of this attribute in the official documentation:
URIENCODING:THIS Specifies the character encoding used to decode the URI bytes, after%xx decoding the URL. If not specified, iso-8859-1 'll be used.
The reference document here is Tomcat5.5, and the pro-test works for TOMCAT7.
Note:
<connector port= "8080" protocol= "http/1.1"
connectiontimeout= "20000"
Redirectport= "8443" usebodyencodingforuri= "true"/>
by usebodyencodingforuri= the "true" configuration and then setting the default request.setcharacterencoding encoding in the code, the garbled problem can be effectively resolved.
, recommended with usebodyencodingforuri= "true"
The problem of parsing the Chinese parameter of Get mode in Spring MVC controller is garbled (how Tomcat decodes)