| The code is 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 <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:
| The code is as follows |
|
XML code <connectorport= "8009" protocol= "ajp/1.3" redirectport= "8443"/> <connector port= "8009" protocol= "ajp/1.3" redirectport= "8443"/> To XML code <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:
| The code is 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.
| The code is 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
| The code is 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:
| The code is 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
| The code is as follows |
|
Stirng str=new String (str.getbytes ("iso-8859-1"), "Development Environment Code"); |