Maven 配置WEB项目时, 不能正常解码请求的中文信息

查询了浏览器提交的信息,中文信息是正常进行uri编码的,但是实际获取到的数据确实乱码;

需要在配置maven中配置tomcat插件时 明确清楚uriEncoding的方式,即可解决这个问题;

        <!--tomcat插件-->
            <plugin>
                <groupId>org.apache.tomcat.maven</groupId>
                <!-- tomcat7的插件, 不同tomcat版本这个也不一样 -->
                <artifactId>tomcat7-maven-plugin</artifactId>
                <version>2.1</version>
                <configuration>
                    <!-- 通过maven tomcat7:run运行项目时,访问项目的端口号 -->
                    <port>80</port>
                    <!-- 项目访问路径  本例:localhost:9090,  如果配置的aa, 则访问路径为localhost:9090/aa-->
                    <uriEncoding>UTF-8</uriEncoding>
                    <path>/travel</path>
                </configuration>
            </plugin>

 

posted @ 2021-06-25 16:33  小人物_大情怀  阅读(74)  评论(0)    收藏  举报