将http://localhost:8080设置为项目主页
1.需求:
访问:http://localhost:8080 进入项目主页-登陆页
2.实现:
2.1.将整个项目复制并替换掉tomcat/webapps/ROOT目录下所有文件。
2.2.修改tomcat/conf/server.xml文件,将Host标签中添加 <Context path="" docBase="项目名" reloadable="true" useHttpOnly="true" />,代码如下:
<Host appBase="webapps" autoDeploy="true" name="localhost" unpackWARs="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" pattern="%h %l %u %t "%r" %s %b" prefix="localhost_access_log" suffix=".txt"/> <Context path="" docBase="项目名" reloadable="true" useHttpOnly="true" /> </Host>
3.测试
输入:http://localhost:8080 效果如下: