使用eclipse并且用mvn命令启动java web项目,
并使用
tomcat:run
的方式启动。
那你的编码会跟随内置的mvn 内置的tomcat编码, 导致乱码。
此时就需要强行指定tomcat的编码。启动了。
-Dmaven.tomcat.uriEncoding=UTF-8 tomcat:run
使用上述命令强制设置为uft-8启动,即可。
或者在pom.xml里面指定tomcat 插件版本也行
<build>
<plugins>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<path>/</path> <!--项目访问路径。当前配置的访问是localhost:9090/, 如果配置是/aa,则访问路径为localhost:9090/aa -->
<port>9090</port>
<uriEncoding>UTF-8</uriEncoding><!-- 非必需项 -->
</configuration>
</plugin>
</plugins>
</build>
由于项目是很久以前的开源项目存在各种各样的问题,时间又要求很急,改起来真的费劲。
确实 此方式跑项目非主流,但仍然有像我一样的人。。。。
这坑踩的头皮发麻。