美文网首页
jsp/servlet乱码解决

jsp/servlet乱码解决

作者: 蘋果_283e | 来源:发表于2017-03-30 18:51 被阅读0次

    1 解决方法 <% @ page contentType = " text/html;charset=utf-8 "  %>

    2 response.setCharacterEncoding("utf-8");//响应编码类型response.setContentType("text/html;charset=utf-8");//设置文档类型request.setCharacterEncoding("utf-8");//请求编码类型

    3 new String(request.getParameter("name").getBytes("ISO8859_1"),"utf-8");

    4 修改tomcat的server.xml

    <Connector port="8080" protocol="HTTP/1.1"

    connectionTimeout="20000"

    redirectPort="8443" URIEncoding="utf-8"

    />

    5过滤器配置web.xml

    <filter>

    <filter-name>w1</filter-name>Set Character Encoding

    <filter-class>com.hw.controller.ErrorFilter</filter-class>SetCharacterEncodingFilter

    </filter>

    <filter-mapping>

    <filter-name>w1</filter-name>Set Character Encoding

    <url-pattern>/*</url-pattern>

    </filter-mapping>

    qq

    con.hw.controller.EncodingFilter

    qq

    /*

    qq

    con.hw.controller.EncodingFilter

    qq

    /*

    相关文章

      网友评论

          本文标题:jsp/servlet乱码解决

          本文链接:https://www.haomeiwen.com/subject/khcsottx.html