Issue 1:SPRINGMVC returns values (including Chinese characters) to the page via @responsebody, garbled
Solution:
After the springmvc3.2 can be declared note drive (do not know is not so translated) when the control of the code conversion, the result is so solved, too handsome!
<Mvc:annotation-driven> <mvc:message-converters> <!--default stringhttpmessageconverter, solve encoding problem - <Beanclass= "Org.springframework.http.converter.StringHttpMessageConverter"> <Constructor-argvalue= "UTF-8" /> < Propertyname= "Writeacceptcharset"value= "false" /> </Bean> </mvc:message-converters> </Mvc:annotation-driven>
Issue 2: (Note: This method only resolves the garbled post request)
JSP page Chinese input, to controller garbled, this time needs to be set to add a coded filter in the Web. xml file (filter) to unify the encoding to UTF-8, the code is as follows:
Web. XML configuration file:
<Filter> <Filter-name>Encodingfilter</Filter-name> <Filter-class>Org.springframework.web.filter.CharacterEncodingFilter</Filter-class> <Init-param> <Param-name>Encoding</Param-name> <Param-value>UTF-8</Param-value> </Init-param> <Init-param> <Param-name>Forceencoding</Param-name> <Param-value>True</Param-value> </Init-param> </Filter> <filter-mapping> <Filter-name>Encodingfilter</Filter-name> <Url-pattern>/*</Url-pattern> </filter-mapping>
It is important to note that it is best to place this code at the beginning of the Web. XML because the interception is in order and is easily intercepted if placed behind.
Problem 3:get Request garbled
Add the Server.xml file in the Tomcat server uriencoding= "UTF-8
Such as:
<connectiontimeout= "20000" port= "8080" protocol = "http/1.1" Redirectport = "8443" uriencoding= "UTF-8" />
Summary of Web request garbled problem