struct2,springmvc,servlet编码问题

一般乱码问题指的是请求编码和相应编码乱码的问题

  servlet 请求编码乱码 

    get  三步走 

      String name = request.getParameter(“name”);

      name = new String(name.getBytes(“iso-8859-1”), “utf-8”);

    post request.setCharacterEncoding("utf-8")

  相应编码乱码  转发或重定向到.jsp不会乱码 ,因为.jsp中含有content-type

        response.getWriter.print() 会乱码  浏览器和服务器编码不一致,解决办法 response.setContentType("text/html,charset=utf-8"),使服务器发送出去的数据(out.print)都

        是utf-8(tomcat将gbk或iso编码转化为了utf-8)

  struct2默认request编码为utf-8 无请求编码问题

  spring请求会乱码

 day10 ,day12有详细讲解

原文地址:https://www.cnblogs.com/lt123/p/7461461.html