zoukankan      html  css  js  c++  java
  • spring mvc 乱码

    高了半天的乱码问题,搜这里搜那里的。

    如果spring mvc 中文不想乱码,总结三点:

    1.前端设定utf-8编码

    <head>
            <meta charset="UTF-8">
    </head>

    2.tomcat 设定的utf-8编码 

     <Connector executor="tomcatThreadPool"
                   port="8090" protocol="HTTP/1.1"
                   connectionTimeout="20000"
                   redirectPort="8443" URIEncoding="utf-8"/>

    3.工程后台在web.xml文件中设置过滤器filter

        <filter>
            <filter-name>characterEncodingFilter</filter-name>
            <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
            <init-param>
                <param-name>encoding</param-name>
                <param-value>UTF-8</param-value>
            </init-param>
        </filter>
        <filter-mapping>
            <filter-name>characterEncodingFilter</filter-name>
            <url-pattern>/*</url-pattern>
        </filter-mapping>
    原创博文,未经许可不得转载,转载请注明出处。
  • 相关阅读:
    错题
    URL和URI区别
    适配器
    JAVA 反射机制
    JAVA 面试题
    JAVA 继承
    多态 JAVA
    Java面向对象编辑
    [LeetCode] Merge k Sorted Lists
    [LeetCode] Valid Palindrome
  • 原文地址:https://www.cnblogs.com/Think-007/p/7527629.html
Copyright © 2011-2022 走看看