When jsp passes the value through the URL, the Chinese garbled problem can be solved in two ways

The first one is a bit troublesome

JSP page: var url = "AddPatrolAjax?domain=" +domain.value; //domain.value contains Chinese

服务器端:String domain = newString(request.getParameter("domain").getBytes( "ISO-8859-1"), "utf-8");

First get byte[], then newString(byte[], charset)

Second, you need to set tomcat

This sentence in tomcat's configuration file server.xml:

<Connector URIEncoding="GB2312"
port="8080"   maxHttpHeaderSize="8192"
               maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
               enableLookups="false" redirectPort="8443" acceptCount="100"
               connectionTimeout="20000" disableUploadTimeout="true" />
 
Add this sentence: URIEncoding="UTF-8"


I have tested both of the above methods and can use

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326564840&siteId=291194637