问题描述:
今天启动一个ssm 项目,使用tomcat 启动,idea 日志窗口中文乱码
解决思路:
因为项目中有中文,肯定是哪里配置了UTF-8,但是有些地方又配置了其他的编码。比如:GBK。我们默认全部设置成UTF-8 即可。
解决步骤:
一,修改server.xml 的配置
打开tomcat 下的conf/server.xml ,在七十行左右插入代码 URIEcoding = "UTF-8"
<Connector port="7080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" URIEncoding="UTF-8"/>
二,修改logging.properties 配置
打开tomcat 下的conf/logging.properties,添加一下代码
1catalina.org.apache.juli.AsyncFileHandler.encoding = UTF-8
2localhost.org.apache.juli.AsyncFileHandler.encoding = UTF-8
3manager.org.apache.juli.AsyncFileHandler.encoding = UTF-8
4host-manager.org.apache.juli.AsyncFileHandler.encoding = UTF-8
java.util.logging.ConsoleHandler.encoding = UTF-8
三,修改tomcat idea 配置
-Dfile.encoding=UTF-8
四,修改idea vm options
在help->Edit Custom VM Options...,添加 -Dfile.encoding=UTF-8
重启即可。
采用如下配置即可,我看好多都是修改成GBK 的,但是我改成GBK无效。可自行判断下