JSP struts2 url pass-through Chinese garbled solution
1. Settings
<constant name="struts." value="UTF-8" />
Or settings (I haven't tried it myself)
struts.=UTF-8
2. Add an encoding filter
<filter> <filter-name>characterEncodingFilter</filter-name> <filter-class></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> <filter-name>characterEncodingFilter</filter-name> <filter-class></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>
The above uses spring, you can also write it yourself, and the core statement is ();
3. Set the configuration of tomcat
Both 1 and 2 can only set the encoding method of submitting data in post. If the url has Chinese, there will be garbled code. The solution is
Tomcat's \conf\server file
<Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" URIEncoding="UTF-8"/>
<Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" URIEncoding="UTF-8"/>
Join URIEncoding="UTF-8". If you are using eclipse, remember to restart eclipse, delete the server settings, and reset them. I did not do this and the configuration file did not take effect. I debugged for a long time.
Thank you for reading, I hope it can help you. Thank you for your support for this site!