1.设置eclips , window->Preferences->web->JSP Files中的Encoding选项为UTF-8
2.修改jsp文件头部为UTF-8
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
3.设置servlet中request对象编码
public class RegisterServlet extends HttpServlet{
public void doGet(HttpServletRequest request,HttpServletResponse response)
throws ServletException,IOException{
request.setCharacterEncoding("UTF-8");
........
}
}
4.如果还是乱码,设置tomat中的配置文件
Tomcat的server.xml文档中的 <Connector> 配置中增加
useBodyEncodingForURI="true" IEncoding="utf-8" URIEncoding="utf-8"