JavaWeb

javaWeb Servlet转发中文乱码解决

这里使用的是Eclipse with javaEE 写的项目(与MyEclipse基本无异)

  1. 将数据库编码类型修改为UTF-8
    huyunfei
    本文链接:https://blog.****.net/huyunfei/article/details/100916592
  2. jsp页面修改为UTF编码
  3. Servlet中设置
    request.setCharacterEncoding(“utf-8”);
    response.setCharacterEncoding(“utf-8”);
    response.setContentType(“text/text;charset=utf-8”);
  4. 删除自动生成的 response.getWriter().append("Served at: ").append(request.getContextPath());

JavaWeb在jsp页面设置编码方式

JavaWeb
设置Servlet编码
(这里是使用doGet方式)如果是使用的doGet方式需要在doGet方法里写
JavaWeb
处理完成,中文乱码解决