1、项目工程编码统一采用UTF-8编码
2、JSP页面采用UTF-8编码
1
|
<%@ page language=
"java"
import
=
"java.util.*,entity.Student"
pageEncoding=
"UTF-8"
%>
|
3、设置request内置对象采用utf-8编码,防止表单提交产生信息乱码(POST方式提交)
1
|
request.setCharacterEncoding(
"utf-8"
);
|
4、设置设置Tomcat的get方式提交采用UTF-8提编码(GET方式提交)
1
2
3
|
<
Connector
port
=
"8080"
protocol
=
"HTTP/1.1"
connectionTimeout
=
"20000"
redirectPort
=
"8443"
URIEncoding
=
"UTF-8"
/>
|
等效于:
1
|
String user =
new
String(request.getParameter(
"user"
).getBytes(
"ISO-8859-1"
),
"UTF-8"
)
|
本文转自stock0991 51CTO博客,原文链接:http://blog.51cto.com/qing0991/1427210,如需转载请自行联系原作者