web.xml中的welcome-file(访问相对路径时配置默认访问文件)

传说中的北京呢?

---xingyunpi

jsp web project中,一般情况下,在WEB-INF中可以配置默认的访问文件名称,一般情况下是index.html.

遇到的问题:

首先,在TOMCATHOME/conf/server.xml中配置了一个虚拟目录 admin.sorina ,指向项目中某个文件夹,比如:test(项目名称)/webmaster/admin/,这个时候,在访问admin.sorina/的时候,就会访问admin下的index.html,但是,按照这种思路,我在WEB-INF中配置了一个welcome-file,指定访问list_1_1.html,但是,用相对路径访问,如访问:admin.sorina/login/的时候,我的目的相当于访问test(项目名称)/webmaster/admin/login/list_1_1.html,但是,这个时候却是出现404错误.

解决的办法:

好像是用这种相对路径访问的方式来配置welcome-file是不通的,要在在TOMCATHOME/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>index.html</welcome-file>
        <welcome-file>index.htm</welcome-file>
        <welcome-file>list_1_1.html</welcome-file>
        <welcome-file>index.jsp</welcome-file>
    </welcome-file-list>
同时在 WEB-INF/web.xml中进行对应配置:

<welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>list_1_1.html</welcome-file>
    <welcome-file>index.html</welcome-file>
  </welcome-file-list>

这样,就能正常访问了.

评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值