比如首页为:/jpress_web/hello.jsp
1、修改tomcat/conf/service.xml文件
找到文件:
<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">
<Context path="" docBase="jpress_web" debug="0" reloadable="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 -->
<!--
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log." suffix=".txt" pattern="common" resolveHosts="false"/>
-->
</Host>
添加:<Context path="" docBase="jpress_web" debug="0" reloadable="true" />
path 指的是虚拟路径,如果为空,表示是: http://域名
如果为“abc”,则表示访问地址为: http://域名/abc
docBase是虚拟目录的路径,可以写绝对路径,也可以写相对路径,相对路径指的是webapps下的项目名。
2、修改tomcat/conf/web.xml文件
找到如下(文档的最后面):
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
在<welcome-file-list>标签里添加
<welcome-file>hello.jsp</welcome-file>
3、重启tomcat后,可以直接通过域名访问