大家好,又见面了,我是你们的朋友全栈君。
1、将项目打成WAR包放在Tomcat的webapps目录下
2、在Tomcat的安装目录的conf下找到server.xml的文件,如:D:apache-tomcat-9.0.8confserver.xml
3、在Host标签里边添加
<Host name=”localhost” appBase=”webapps” unpackWARs=”true” autoDeploy=”true”> <!– SingleSignOn valve, share authentication between web applications Documentation at: /docs/config/valve.html –> <!– <Valve className=”org.apache.catalina.authenticator.SingleSignOn” /> –> <!– Access log processes all example. Documentation at: /docs/config/valve.html Note: The pattern used is equivalent to using pattern=”common” –> <Valve className=”org.apache.catalina.valves.AccessLogValve” directory=”logs” prefix=”localhost_access_log” suffix=”.txt” pattern=”%h %l %u %t “%r” %s %b” /> <Context path=”” docBase=”myproject” reloadable=”true” /> </Host>
Context标签内容,注意path填空,docBase为项目名称
4、再次访问即可携带项目名称或不带都可以访问到项目。如localhost:8080/或localhost:8080/myproject
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/145886.html原文链接:https://javaforall.cn