java页面中文乱码解决方法
内容摘要
1、设置eclips , window->Preferences->web->JSP Files中的Encoding选项为UTF-82、修改jsp文件头部为UTF-8<%@ page language="java" contentType="text/html; charset=UTF-
文章正文
1、设置eclips , window->Preferences->web->JSP Files中的Encoding选项为UTF-8
2、修改jsp文件头部为UTF-8
1 2 | <%@ page language= "java" contentType= "text/html; charset=UTF-8" pageEncoding= "UTF-8" %> |
3、设置servlet中request对象编码
1 2 3 4 5 6 7 8 9 10 11 | 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> 配置中增加
1 | useBodyEncodingForURI= "true" IEncoding= "utf-8" URIEncoding= "utf-8" |
更多java知识请关注java基础教程栏目。
代码注释
[!--zhushi--]