IDEA中使用tomcat9時出現(xiàn)亂碼解決方法
1韧骗、修改IDEA中setting的設置Editor——File Encodings
2桥氏、修改apache-tomcat-9.0.50\conf\logging.properties文件青灼,修改如下參數(shù):
############################################################
# Handler specific properties.
# Describes specific configuration info for Handlers.
############################################################
1catalina.org.apache.juli.AsyncFileHandler.level = FINE
1catalina.org.apache.juli.AsyncFileHandler.directory = ${catalina.base}/logs
1catalina.org.apache.juli.AsyncFileHandler.prefix = catalina.
1catalina.org.apache.juli.AsyncFileHandler.maxDays = 90
1catalina.org.apache.juli.AsyncFileHandler.encoding = UTF-8
2localhost.org.apache.juli.AsyncFileHandler.level = FINE
2localhost.org.apache.juli.AsyncFileHandler.directory = ${catalina.base}/logs
2localhost.org.apache.juli.AsyncFileHandler.prefix = localhost.
2localhost.org.apache.juli.AsyncFileHandler.maxDays = 90
2localhost.org.apache.juli.AsyncFileHandler.encoding = UTF-8
3manager.org.apache.juli.AsyncFileHandler.level = FINE
3manager.org.apache.juli.AsyncFileHandler.directory = ${catalina.base}/logs
3manager.org.apache.juli.AsyncFileHandler.prefix = manager.
3manager.org.apache.juli.AsyncFileHandler.maxDays = 90
3manager.org.apache.juli.AsyncFileHandler.encoding = UTF-8
4host-manager.org.apache.juli.AsyncFileHandler.level = FINE
4host-manager.org.apache.juli.AsyncFileHandler.directory = ${catalina.base}/logs
4host-manager.org.apache.juli.AsyncFileHandler.prefix = host-manager.
4host-manager.org.apache.juli.AsyncFileHandler.maxDays = 90
4host-manager.org.apache.juli.AsyncFileHandler.encoding = UTF-8
java.util.logging.ConsoleHandler.level = FINE
java.util.logging.ConsoleHandler.formatter = org.apache.juli.OneLineFormatter
java.util.logging.ConsoleHandler.encoding = GBK
分析其原因卷仑,當所有都是UTF-8時孽尽,IDEA默認字符集是GBK會出現(xiàn)中文字符集錯誤于游,導致亂碼問題毁葱,而我們對于控制臺打印使用的字符集設置為GBK,與windows環(huán)境下IDEA的默認字符集一致贰剥,因此可以解決倾剿。
后續(xù)會補充如何修改IDEA默認字符集。
本文聲明
知識共享許可協(xié)議 本作品由 cn華少 采用 知識共享署名-非商業(yè)性使用 4.0 國際許可協(xié)議 進行許可蚌成。