Tomcat用【starup.bat】启动,命令行出现乱码
解决方法:
进入Tomcat安装目录下的conf目录
编辑【logging.properties】
将【java.util.logging.ConsoleHandler.encoding】从UTF-8改为GBK
java.util.logging.ConsoleHandler.level=FINEjava.util.logging.ConsoleHandler.formatter=org.apache.juli.OneLineFormatter#java.util.logging.ConsoleHandler.encoding=UTF-8java.util.logging.ConsoleHandler.encoding=GBK
用【starup.bat】启动,正常显示
IDEA运行Tomcat,Tomcat Catalina出现乱码
05-May-202109:33:37.753淇℃伅 [main] org.apache.catalina.startup.VersionLoggerListener.log鍛戒护琛屽弬鏁帮細-Dcatalina.home=D:\apache-tomcat-9.0.45-windows-x64\apache-tomcat-9.0.4505-May-202109:33:37.753淇℃伅 [main] org.apache.catalina.startup.VersionLoggerListener.log鍛戒护琛屽弬鏁帮細-Djava.io.tmpdir=D:\apache-tomcat-9.0.45-windows-x64\apache-tomcat-9.0.45\temp05-May-202109:33:37.753淇℃伅 [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent浣跨敤APR鐗堟湰[1.7.0]鍔犺浇浜嗗熀浜嶢PR鐨凙pacheTomcat鏈満搴揫1.2.27]銆�05-May-202109:33:37.753淇℃伅 [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEventAPR鍔熻兘锛欼Pv6[true]銆乻endfile[true]銆乤cceptfilters[false]銆乺andom[true]銆�05-May-202109:33:37.753淇℃伅 [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEventAPR/OpenSSL閰嶇疆锛歶seAprConnector[false]锛寀seOpenSSL[true] 05-May-202109:33:37.753淇℃伅 [main] org.apache.catalina.core.AprLifecycleListener.initializeSSLOpenSSL鎴愬姛鍒濆鍖� [OpenSSL1.1.1k25Mar2021] 05-May-202109:33:37.938淇℃伅 [main] org.apache.coyote.AbstractProtocol.init鍒濆鍖栧崗璁鐞嗗櫒 ["http-nio-8080"] 05-May-202109:33:37.954淇℃伅 [main] org.apache.catalina.startup.Catalina.load鏈嶅姟鍣ㄥ湪[363]姣鍐呭垵濮嬪寲05-May-202109:33:37.985淇℃伅 [main] org.apache.catalina.core.StandardService.startInternal姝e湪鍚姩鏈嶅姟[Catalina] 05-May-202109:33:37.985淇℃伅 [main] org.apache.catalina.core.StandardEngine.startInternal姝e湪鍚姩Servlet寮曟搸锛歔ApacheTomcat/9.0.45] 05-May-202109:33:37.985淇℃伅 [main] org.apache.coyote.AbstractProtocol.start寮�濮嬪崗璁鐞嗗彞鏌刐"http-nio-8080"] 05-May-202109:33:38.007淇℃伅 [main] org.apache.catalina.startup.Catalina.start [40]姣鍚庢湇鍔″櫒鍚姩05-May-202109:33:48.016淇℃伅 [Catalina-utility-1] org.apache.catalina.startup.HostConfig.deployDirectory鎶妛eb搴旂敤绋嬪簭閮ㄧ讲鍒扮洰褰� [D:\apache-tomcat-9.0.45-windows-x64\apache-tomcat-9.0.45\webapps\manager] 05-May-202109:33:48.078淇℃伅 [Catalina-utility-1] org.apache.catalina.startup.HostConfig.deployDirectoryWeb搴旂敤绋嬪簭鐩綍[D:\apache-tomcat-9.0.45-windows-x64\apache-tomcat-9.0.45\webapps\manager]鐨勯儴缃插凡鍦╗62]姣鍐呭畬鎴�
解决方法:
进入Tomcat安装目录下的conf目录
编辑【logging.properties】
将对应的编码UTF-8改为GBK
1catalina.org.apache.juli.AsyncFileHandler.level=FINE1catalina.org.apache.juli.AsyncFileHandler.directory=${catalina.base}/logs1catalina.org.apache.juli.AsyncFileHandler.prefix=catalina. 1catalina.org.apache.juli.AsyncFileHandler.maxDays=901catalina.org.apache.juli.AsyncFileHandler.encoding=GBK2localhost.org.apache.juli.AsyncFileHandler.level=FINE2localhost.org.apache.juli.AsyncFileHandler.directory=${catalina.base}/logs2localhost.org.apache.juli.AsyncFileHandler.prefix=localhost. 2localhost.org.apache.juli.AsyncFileHandler.maxDays=902localhost.org.apache.juli.AsyncFileHandler.encoding=GBK3manager.org.apache.juli.AsyncFileHandler.level=FINE3manager.org.apache.juli.AsyncFileHandler.directory=${catalina.base}/logs3manager.org.apache.juli.AsyncFileHandler.prefix=manager. 3manager.org.apache.juli.AsyncFileHandler.maxDays=903manager.org.apache.juli.AsyncFileHandler.encoding=GBK4host-manager.org.apache.juli.AsyncFileHandler.level=FINE4host-manager.org.apache.juli.AsyncFileHandler.directory=${catalina.base}/logs4host-manager.org.apache.juli.AsyncFileHandler.prefix=host-manager. 4host-manager.org.apache.juli.AsyncFileHandler.maxDays=904host-manager.org.apache.juli.AsyncFileHandler.encoding=GBKjava.util.logging.ConsoleHandler.level=FINEjava.util.logging.ConsoleHandler.formatter=org.apache.juli.OneLineFormatter#java.util.logging.ConsoleHandler.encoding=UTF-8java.util.logging.ConsoleHandler.encoding=GBK
重新部署,正常显示
05-May-202109:45:44.532信息 [main] org.apache.catalina.startup.VersionLoggerListener.log命令行参数:-Dcatalina.home=D:\apache-tomcat-9.0.45-windows-x64\apache-tomcat-9.0.4505-May-202109:45:44.532信息 [main] org.apache.catalina.startup.VersionLoggerListener.log命令行参数:-Djava.io.tmpdir=D:\apache-tomcat-9.0.45-windows-x64\apache-tomcat-9.0.45\temp05-May-202109:45:44.532信息 [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent使用APR版本[1.7.0]加载了基于APR的ApacheTomcat本机库[1.2.27]。05-May-202109:45:44.532信息 [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEventAPR功能:IPv6[true]、sendfile[true]、acceptfilters[false]、random[true]。05-May-202109:45:44.532信息 [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEventAPR/OpenSSL配置:useAprConnector[false],useOpenSSL[true] 05-May-202109:45:44.532信息 [main] org.apache.catalina.core.AprLifecycleListener.initializeSSLOpenSSL成功初始化 [OpenSSL1.1.1k25Mar2021] 05-May-202109:45:44.725信息 [main] org.apache.coyote.AbstractProtocol.init初始化协议处理器 ["http-nio-8080"] 05-May-202109:45:44.732信息 [main] org.apache.catalina.startup.Catalina.load服务器在[363]毫秒内初始化05-May-202109:45:44.763信息 [main] org.apache.catalina.core.StandardService.startInternal正在启动服务[Catalina] 05-May-202109:45:44.763信息 [main] org.apache.catalina.core.StandardEngine.startInternal正在启动Servlet引擎:[ApacheTomcat/9.0.45] 05-May-202109:45:44.779信息 [main] org.apache.coyote.AbstractProtocol.start开始协议处理句柄["http-nio-8080"] 05-May-202109:45:44.779信息 [main] org.apache.catalina.startup.Catalina.start [50]毫秒后服务器启动
浏览器访问http://localhost:8080出现404
解决方法:
编辑配置
【部署】→【程序上下文】改为/
重新部署即可访问了