Garbled characters may occur when parameters are passed in the URL on the JSP page.
The solution is as follows:
1. Use the method to change tomcat. This method is simple, but it must be modified at the server software level. If the system is slightly changed, transcoding cannot be performed correctly and portability is not high.
1. Go to the Tomcat directory, find the server. xml price under the conf directory, open it, find the <connector> tag, and add uriencoding = 'gbk' at the end. The effect is as follows:
<Connectorport="8080" maxThreads="150" minSpareThreads="25" maxSpareThreads="75"enableLookups="false" redirectPort="8443" acceptCount="100"debug="0" connectionTimeout="20000"disableUploadTimeout="true" URIEncoding=″GBK″/>
This method is successfully tested for the get method.
2. Add the following code on each JSP page:
<%@ page pageEncoding=”gb2312″%><%@ page contentType=”text/html;charset=gb2312″%><%request.setCharacterEncoding(”gb2312″);%>
The encoding method can also be changed to GBK, which supports traditional Chinese. Restart tomcat. This step is very important; otherwise, the effect may not be visible.
This method is successfully tested for post. We recommend that you use two types of synchronization.
Ii. use JSP scriptlet
<%=new String(elValue.getBytes("iso-8859-1"),"GBK")%>
3. Use custom jstl
This is our key point, which should be described in detail here.
First, write custom tags
Second, compile the Tag file.
Third, deploy the Tag file
Fourth, use it.) It's very simple.
<To be continued... add the above when you are free>