中文解决方法
一、Tomcat本身的Get与Post中文处理方法
1、从webapps/jsp-examples/WEB-INF/classes/下拷贝filters目录到YourAPP的classes目录下
2、设置Tomcat的Server.xml配置文件在<Connector中增加URIEncoding="GBK"成如下
<Connector port="8080" maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
enableLookups="false" redirectPort="8443" acceptCount="100"
debug="0" connectionTimeout="20000"
disableUploadTimeout="true"
URIEncoding="GBK"/>
3、在应用程序的配置文件web.xml中<web-app>增加
<filter>
<filter-name>Set Character Encoding</filter-name>
<filter-class>filters.SetCharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>GBK</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>Set Character Encoding</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
二、代码修改
1、JSP文件的修改
在首句加上:
<%@ page contentType="text/html;charset=GBK"%>
以显示中文
2、new String((request.getParameter("caseData")).getBytes("ISO-8859-1"),"GBK");
JDBC源:
jdbc:mysql://localhost/Test?autoReconnect=true&useUnicode=true&characterEncoding=GB2312
一、Tomcat本身的Get与Post中文处理方法
1、从webapps/jsp-examples/WEB-INF/classes/下拷贝filters目录到YourAPP的classes目录下
2、设置Tomcat的Server.xml配置文件在<Connector中增加URIEncoding="GBK"成如下
<Connector port="8080" maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
enableLookups="false" redirectPort="8443" acceptCount="100"
debug="0" connectionTimeout="20000"
disableUploadTimeout="true"
URIEncoding="GBK"/>
3、在应用程序的配置文件web.xml中<web-app>增加
<filter>
<filter-name>Set Character Encoding</filter-name>
<filter-class>filters.SetCharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>GBK</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>Set Character Encoding</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
二、代码修改
1、JSP文件的修改
在首句加上:
<%@ page contentType="text/html;charset=GBK"%>
以显示中文
2、new String((request.getParameter("caseData")).getBytes("ISO-8859-1"),"GBK");
JDBC源:
jdbc:mysql://localhost/Test?autoReconnect=true&useUnicode=true&characterEncoding=GB2312