标签:
<HEAD>
...
<META http-equiv=Content-Type content="text/html;charset=utf-8">
...
<HEAD>
<%@ page contentType="text/html;charset=utf-8" language="java"%>
request.setCharacterEncoding("utf-8");
response.setContentType("text/html;charset=utf-8");
<!--定义编码过滤器-->
<filter>
<filter-name>encodingFilter</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>utf-8</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>encodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
String param = request.getParameter("param");
param = new String(param.getBytes("ISO-8859-1", "utf-8"));
也可以通过修改Tomcat的server.xml文件来解决:
<Connector port = "8080"
...
URIEncoding="utf-8"/> -->增加这项
jdbc:mysql://localhost/test?user=root&password=123456&useUnicode=true&characterEncoding=utf8
"jdbc:microsoft:sqlserver://hzz:1433;useUnicode=true&characterEncoding=gb2312;databaseName=Heros","sa","13871955777"
标签:
原文地址:http://www.cnblogs.com/hzzhero/p/4705825.html