指定tomcat具体的某个项目文件为主页面

本文介绍如何通过修改Tomcat的service.xml和web.xml文件来设置默认访问的首页为特定的JSP页面,并提供了详细的步骤说明。

比如首页为:/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后,可以直接通过域名访问


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值