Garbled characters appear in the Action when the URL of the jsp page is passed to the Chinese parameter, which cannot be solved by the filter or controller. It took me more than two hours to solve this problem!
There are several solutions:
First: Used in Action
Java code
New String (str. getBytes ("ISO8859_1"), "UTF8 ")
Transcoding, because during the transfer, the Chinese speaker is ISO8859_1
Solution 2: You can configure TOMCAT to solve this problem. The specific solution is as follows: in tomcat server. xml, find
Java code
<Connection port = "8080"
MaxThreads = "150" minSpareThreads = "25" maxSpareThreads = "75"
EnableLookups = "false" redirectPort = "8443" acceptCount = "100"
Debug = "0" connectionTimeout = "20000"
DisableUploadTimeout = "true" useBodyEncodingForURI = "true" URIEncoding = "gbk">
Here is the Modification
Java code
DisableUploadTimeout = "true" useBodyEncodingForURI = "true" URIEncoding = "gbk"
The method is to prevent garbled characters in the url.
Add the following code on each Jsp page:
Java code
<% @ Page pageEncoding = "gb2312" %>
<% @ Page contentType = "text/html; charset = gb2312" %>
<% Request. setCharacterEncoding ("gb2312"); %>
Method 3: Use the following method in ACTION:
Java code
Request. setCharacterEncoding ("gb2312 ");
Response. setCharacterEncoding ("gb2312 ");
Author: "The fire of xingling ~"