您好,登錄后才能下訂單哦!
這篇文章主要為大家展示了“如何解決啟動Tomcat時出現大量亂碼的問題”,內容簡而易懂,條理清晰,希望能夠幫助大家解決疑惑,下面讓小編帶領大家一起研究并學習一下“如何解決啟動Tomcat時出現大量亂碼的問題”這篇文章吧。
1. 在 tomcat 的啟動窗口打印的啟動信息中包含了大量的中文亂碼,雖然這些對 tomcat 本身的使用沒有任何影響,但卻非常礙眼,影響視覺效果!
D:\jar\apache-tomcat-7.0.109\bin\catalina.bat run [2021-06-15 12:06:55,652] Artifact ch01hellospringmvc:war exploded: Waiting for server connection to start artifact deployment... Using CATALINA_BASE: "C:\Users\lenovo\.IntelliJIdea2018.3\system\tomcat\Tomcat_7_0_109_springmvc" Using CATALINA_HOME: "D:\jar\apache-tomcat-7.0.109" Using CATALINA_TMPDIR: "D:\jar\apache-tomcat-7.0.109\temp" Using JRE_HOME: "C:\Program Files\Java\jdk1.8.0_40" Using CLASSPATH: "D:\jar\apache-tomcat-7.0.109\bin\bootstrap.jar;D:\jar\apache-tomcat-7.0.109\bin\tomcat-juli.jar" Using CATALINA_OPTS: "" 鍏湀 15, 2021 12:06:59 涓婂崍 org.apache.catalina.startup.VersionLoggerListener log 淇℃伅: Server.鏈嶅姟鍣ㄧ増鏈?: Apache Tomcat/7.0.109 鍏湀 15, 2021 12:06:59 涓婂崍 org.apache.catalina.startup.VersionLoggerListener log 淇℃伅: 鏈嶅姟鍣ㄦ瀯寤?: Apr 22 2021 18:43:38 UTC 鍏湀 15, 2021 12:06:59 涓婂崍 org.apache.catalina.startup.VersionLoggerListener log 淇℃伅: 鏈嶅姟鍣ㄧ増鏈彿: 7.0.109.0 鍏湀 15, 2021 12:06:59 涓婂崍 org.apache.catalina.startup.VersionLoggerListener log 淇℃伅: 鎿嶄綔緋葷粺鍚嶇О: Windows 8.1 鍏湀 15, 2021 12:06:59 涓婂崍 org.apache.catalina.startup.VersionLoggerListener log 淇℃伅: OS.鐗堟湰: 6.3 鍏湀 15, 2021 12:06:59 涓婂崍 org.apache.catalina.startup.VersionLoggerListener log 淇℃伅: 鏋舵瀯: amd64 鍏湀 15, 2021 12:06:59 涓婂崍 org.apache.catalina.startup.VersionLoggerListener log 淇℃伅: Java 鐜鍙橀噺: C:\Program Files\Java\jdk1.8.0_40\jre 鍏湀 15, 2021 12:06:59 涓婂崍 org.apache.catalina.startup.VersionLoggerListener log 淇℃伅: Java铏氭嫙鏈虹増鏈?: 1.8.0_40-b25 鍏湀 15, 2021 12:06:59 涓婂崍 org.apache.catalina.startup.VersionLoggerListener log 淇℃伅: JVM.渚涘簲鍟?: Oracle Corporation 鍏湀 15, 2021 12:06:59 涓婂崍 org.apache.catalina.startup.VersionLoggerListener log 淇℃伅: CATALINA_BASE: C:\Users\lenovo\.IntelliJIdea2018.3\system\tomcat\Tomcat_7_0_109_springmvc 鍏湀 15, 2021 12:06:59 涓婂崍 org.apache.catalina.startup.VersionLoggerListener log 淇℃伅: CATALINA_HOME: D:\jar\apache-tomcat-7.0.109 鍏湀 15, 2021 12:06:59 涓婂崍 org.apache.catalina.startup.VersionLoggerListener log 淇℃伅: 鍛戒護琛屽弬鏁幫細 -Djava.util.logging.config.file=C:\Users\lenovo\.IntelliJIdea2018.3\system\tomcat\Tomcat_7_0_109_springmvc\conf\logging.properties 鍏湀 15, 2021 12:06:59 涓婂崍 org.apache.catalina.startup.VersionLoggerListener log 淇℃伅: 鍛戒護琛屽弬鏁幫細 -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager 鍏湀 15, 2021 12:06:59 涓婂崍 org.apache.catalina.startup.VersionLoggerListener log 淇℃伅: 鍛戒護琛屽弬鏁幫細 -Dcom.sun.management.jmxremote= 鍏湀 15, 2021 12:06:59 涓婂崍 org.apache.catalina.startup.VersionLoggerListener log 淇℃伅: 鍛戒護琛屽弬鏁幫細 -Dcom.sun.management.jmxremote.port=1099 鍏湀 15, 2021 12:06:59 涓婂崍 org.apache.catalina.startup.VersionLoggerListener log 淇℃伅: 鍛戒護琛屽弬鏁幫細 -Dcom.sun.management.jmxremote.ssl=false 鍏湀 15, 2021 12:06:59 涓婂崍 org.apache.catalina.startup.VersionLoggerListener log 淇℃伅: 鍛戒護琛屽弬鏁幫細 -Dcom.sun.management.jmxremote.password.file=C:\Users\lenovo\.IntelliJIdea2018.3\system\tomcat\Tomcat_7_0_109_springmvc\jmxremote.password 鍏湀 15, 2021 12:06:59 涓婂崍 org.apache.catalina.startup.VersionLoggerListener log 淇℃伅: 鍛戒護琛屽弬鏁幫細 -Dcom.sun.management.jmxremote.access.file=C:\Users\lenovo\.IntelliJIdea2018.3\system\tomcat\Tomcat_7_0_109_springmvc\jmxremote.access 鍏湀 15, 2021 12:06:59 涓婂崍 org.apache.catalina.startup.VersionLoggerListener log 淇℃伅: 鍛戒護琛屽弬鏁幫細 -Djava.rmi.server.hostname=127.0.0.1 鍏湀 15, 2021 12:06:59 涓婂崍 org.apache.catalina.startup.VersionLoggerListener log 淇℃伅: 鍛戒護琛屽弬鏁幫細 -Djdk.tls.ephemeralDHKeySize=2048 鍏湀 15, 2021 12:06:59 涓婂崍 org.apache.catalina.startup.VersionLoggerListener log 淇℃伅: 鍛戒護琛屽弬鏁幫細 -Dignore.endorsed.dirs= 鍏湀 15, 2021 12:06:59 涓婂崍 org.apache.catalina.startup.VersionLoggerListener log 淇℃伅: 鍛戒護琛屽弬鏁幫細 -Dcatalina.base=C:\Users\lenovo\.IntelliJIdea2018.3\system\tomcat\Tomcat_7_0_109_springmvc 鍏湀 15, 2021 12:06:59 涓婂崍 org.apache.catalina.startup.VersionLoggerListener log 淇℃伅: 鍛戒護琛屽弬鏁幫細 -Dcatalina.home=D:\jar\apache-tomcat-7.0.109 鍏湀 15, 2021 12:06:59 涓婂崍 org.apache.catalina.startup.VersionLoggerListener log 淇℃伅: 鍛戒護琛屽弬鏁幫細 -Djava.io.tmpdir=D:\jar\apache-tomcat-7.0.109\temp 鍏湀 15, 2021 12:06:59 涓婂崍 org.apache.catalina.core.AprLifecycleListener lifecycleEvent 淇℃伅: 浣跨敤APR鐗堟湰[1.7.0]鍔犺澆浜嗗熀浜嶢PR鐨凙pache Tomcat鏈満搴揫1.2.28]銆? 鍏湀 15, 2021 12:06:59 涓婂崍 org.apache.catalina.core.AprLifecycleListener lifecycleEvent 淇℃伅: APR鍔熻兘錛欼Pv6[true]銆乻endfile[true]銆乤ccept filters[false]銆乺andom[true]銆? 鍏湀 15, 2021 12:06:59 涓婂崍 org.apache.catalina.core.AprLifecycleListener initializeSSL 淇℃伅: OpenSSL鎴愬姛鍒濆鍖? [OpenSSL 1.1.1k 25 Mar 2021] 鍏湀 15, 2021 12:06:59 涓婂崍 org.apache.coyote.AbstractProtocol init 淇℃伅: 鍒濆鍖栧崗璁鐞嗗櫒 ["http-apr-8090"] 鍏湀 15, 2021 12:06:59 涓婂崍 org.apache.catalina.startup.Catalina load 淇℃伅: Initialization processed in 1462 ms 鍏湀 15, 2021 12:06:59 涓婂崍 org.apache.catalina.core.StandardService startInternal 淇℃伅: 姝e湪鍚姩鏈嶅姟[Catalina] 鍏湀 15, 2021 12:06:59 涓婂崍 org.apache.catalina.core.StandardEngine startInternal 淇℃伅: Starting Servlet Engine: Apache Tomcat/7.0.109 鍏湀 15, 2021 12:06:59 涓婂崍 org.apache.coyote.AbstractProtocol start 淇℃伅: 寮?濮嬪崗璁鐞嗗彞鏌刐"http-apr-8090"] 鍏湀 15, 2021 12:06:59 涓婂崍 org.apache.catalina.startup.Catalina start 淇℃伅: Server startup in 108 ms Connected to server [2021-06-15 12:07:00,087] Artifact ch01hellospringmvc:war exploded: Artifact is being deployed, please wait... 鍏湀 15, 2021 12:07:00 涓婂崍 org.apache.catalina.deploy.WebXml setVersion 璀﹀憡: Unknown version string [4.0]. Default version will be used. 鍏湀 15, 2021 12:07:02 涓婂崍 org.apache.catalina.startup.TldConfig execute 淇℃伅: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time. [2021-06-15 12:07:03,217] Artifact ch01hellospringmvc:war exploded: Artifact is deployed successfully [2021-06-15 12:07:03,218] Artifact ch01hellospringmvc:war exploded: Deploy took 3,131 milliseconds 鍏湀 15, 2021 12:07:09 涓婂崍 org.apache.catalina.startup.HostConfig deployDirectory 淇℃伅: 鎶妛eb 搴旂敤紼嬪簭閮ㄧ講鍒扮洰褰? [D:\jar\apache-tomcat-7.0.109\webapps\manager] 鍏湀 15, 2021 12:07:10 涓婂崍 org.apache.catalina.startup.HostConfig deployDirectory 淇℃伅: Web搴旂敤紼嬪簭鐩綍[D:\jar\apache-tomcat-7.0.109\webapps\manager]鐨勯儴緗插凡鍦╗319]姣鍐呭畬鎴?
2. 對于亂碼問題,原因是字節流解碼為字符串時,使用了錯誤的字符集(和編碼所用字符集不一致) !
我們找到 tomcat 目錄下的 config 子目錄中,找到"logging.properties" 文件,打開這個文本文件,找到如下配置項:
java.util.logging.ConsoleHandler.encoding = UTF-8
將 UTF-8 修改為 GBK,修改后的效果為:
java.util.logging.ConsoleHandler.encoding = GBK
保存后,重啟 tomcat
、
最后,重啟窗口,亂碼問題就解決了
以上是“如何解決啟動Tomcat時出現大量亂碼的問題”這篇文章的所有內容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內容對大家有所幫助,如果還想學習更多知識,歡迎關注億速云行業資訊頻道!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。