Solve the problem of garbled Chinese parameters in Get mode:
Method 1:
The premise is that Tomcat is the default configuration:
Key = new String (key. getBytes ("ISO8859-1"), "UTF-8 ");
Method 2:
Set in Tomcat server. xml:
<Connector port = "8080" protocol = "HTTP/1.1" connectionTimeout = "20000" redirectPort = "8443" URIEncoding = "UTF-8" (this is the focus, indicates the default encoding type used for obtaining parameter decoding.)/>
Method 3: (recommended)
1. Perform URL encoding twice on the page:
Param = encodeURI (param );
Use a URL to send a value to the server.
2. Perform URL decoding again in the Action (because URL decoding has been performed once during req. getParameter)
String param = URLDecoder. decode (req. getParameter (param ));
Struts labels solve the garbled problem:
In the struts tag, you can perform URL encoding twice, provided that you have to set it in struts. xml:
<! -- Set to call static methods in OGNL -->
<Constant name = "struts. ognl. allowStaticMethodAccess" value = "true"/>
<S: a action = "processDefinitionAction_delete" onclick = "return delConfirm ()"> <s: param name = "key" value = "% {@ [email protected] (key, 'utf-8')} "> </s: param> delete </s: a>
Solve Chinese garbled characters when the browser passes parameters to the server