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"

 

相关文章:

  • 2021-09-27
  • 2021-09-19
  • 2022-12-23
  • 2022-12-23
  • 2021-07-19
  • 2021-04-29
  • 2021-09-13
猜你喜欢
  • 2021-10-11
  • 2022-12-23
  • 2021-12-09
  • 2021-12-21
  • 2021-11-28
  • 2021-06-25
  • 2022-12-23
相关资源
相似解决方案