On-page submission to Tomcat garbled solution is configured in Tomcat/conf/server.xml
Take tomcat6.0.32 For example, the following code should be used:
XML code
Copy Code code as follows:
<connectorport= "8080" protocol= "http/1.1"
connectiontimeout= "20000"
redirectport= "8443"/>
<connector port= "8080" protocol= "http/1.1"
connectiontimeout= "20000"
redirectport= "8443"/>
To
XML code
Copy Code code as follows:
<connectorport= "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"/>
If the Tomcat front-end has Apache or Nginx forwarding, you will also need to:
XML code
Copy Code code as follows:
<connectorport= "8009" protocol= "ajp/1.3" redirectport= "8443"/>
<connector port= "8009" protocol= "ajp/1.3" redirectport= "8443"/>
To
XML code
Copy Code code as follows:
<connectorport= "8009" protocol= "ajp/1.3" redirectport= "8443" uriencoding= "UTF-8"/>
<connector port= "8009" protocol= "ajp/1.3" redirectport= "8443" uriencoding= "UTF-8"/>
Chinese URL garbled Here is a workaround that can be used in any application deployment environment. This method is divided into two steps:
1, in the client with Escape (encodeURIComponent (Fieldvalue)) method encoding, for example:
Copy Code code as follows:
Title=escape (encodeURIComponent (title)); This is the function in JS.
Url= "<%=request.getcontextpath ()%>/print/printlist!printtable.action?title=" +title;
2, in the service End with Java.net.URLDecoder.decode (Getrequest () getparameter ("title"), "UTF-8"), to decode.
To pass Chinese in these two URL addresses, you must encode and then decode.
Copy Code code as follows:
Encoding: encodeURI (encodeURI ("contains Chinese strings")
Decoding: Java.net.URLDecoder.decode ("strings to be decoded", "Utf-8");
JSP page garbled usually only in the beginning of the page with the following code to specify the character set encoding can be. If not, please use the following sentence to convert
Copy Code code as follows:
Str=new String (str.getbytes ("iso-8859-1"), "page encoding Mode");
Java is used in the network transmission code is "iso-8859-1", so the output needs to be transformed, such as:
Copy Code code as follows:
String Str=new string (str.getbytes ("Development Environment Code"), "iso-8859-1");
After the network encoded Chinese, to correctly display on the page must be used similar to the
Copy Code code as follows:
Stirng str=new String (str.getbytes ("iso-8859-1"), "Development Environment Code");
In this way to decode