乱码样式由于已解决,故没得图了。情景:IDEA启动Tomcat乱码及日志乱码。
解决方案:思路====》1.从Tomcat着手。2.从IDEA着手。
一、先从1入手,步骤如下:
值:-Dfile.encoding=UTF-8
值:
JAVA_OPTS -Dfile.encoding=UTF-8
JAVA_TOOL_OPTIONS -Dfile.encoding=UTF-8
(一般到此重启服务器即可,如还未解决请往下看)
打开tomcat/conf/目录下修改logging.properties
找到"UTF-8"行更改为GBK
1catalina.org.apache.juli.FileHandler.level = FINE
1catalina.org.apache.juli.FileHandler.directory = ${catalina.base}/logs
1catalina.org.apache.juli.FileHandler.prefix = catalina.
1catalina.org.apache.juli.FileHandler.encoding = GBK
2localhost.org.apache.juli.FileHandler.level = FINE
2localhost.org.apache.juli.FileHandler.directory = ${catalina.base}/logs
2localhost.org.apache.juli.FileHandler.prefix = localhost.
2localhost.org.apache.juli.FileHandler.encoding = GBK
3manager.org.apache.juli.FileHandler.level = FINE
3manager.org.apache.juli.FileHandler.directory = ${catalina.base}/logs
3manager.org.apache.juli.FileHandler.prefix = manager.
3manager.org.apache.juli.FileHandler.encoding = GBK
4host-manager.org.apache.juli.FileHandler.level = FINE
4host-manager.org.apache.juli.FileHandler.directory = ${catalina.base}/logs
4host-manager.org.apache.juli.FileHandler.prefix = host-manager.
4host-manager.org.apache.juli.FileHandler.encoding = GBK
java.util.logging.ConsoleHandler.level = FINE
java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter
java.util.logging.ConsoleHandler.encoding = GBK
为了防止tomcat传输中得中文乱码,修改tomcat编码如下:
URIEncoding=“UTF-8”
(至此Tomcat相关全部设置完毕,重启运行,看是否还有乱码,如还有问题继续往下看)
二、配置IDEA编码格式。
-
进入设置界面:
set===>editor===>file encoding 全部设置为UTF-8
(到这重启IDEA及Tomcat,看是否正常,如果还有乱发,请看最后一步)
2.找到IDEA的安装文件夹,bin文件下,修改idea.exe.vmoptions和idea64.exe.vmoptions
分别加入如下两句代码:
-Dfile.encoding=UTF-8
-Dconsole.encoding=UTF-8
设置完,请喝杯水或者抽*,静待IDEA重启,重启Tomcat。(如果你也设置到了这一步,求我当时的阴影面积。突然它觉得中文瞬间自通了。兄弟,我在这嘎达等着你。^ _ ^ )