加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Java > 正文

Java Sevlet Mapping.欢迎文件列表

发布时间:2020-12-14 23:46:15 所属栏目:Java 来源:网络整理
导读:在我的web.xml文件中,我有这个 !-- WELCOME FILE LIST --welcome-file-list welcome-file/index/welcome-file/welcome-file-list 哪个映射到此 !-- SERVLET FOR THE HOME PAGE --servlet servlet-nameHomePageServlet/servlet-name servlet-classcom.gmustud
在我的web.xml文件中,我有这个
<!-- WELCOME FILE LIST -->
<welcome-file-list>
    <welcome-file>/index</welcome-file>
</welcome-file-list>

哪个映射到此

<!-- SERVLET FOR THE HOME PAGE -->
<servlet>
    <servlet-name>HomePageServlet</servlet-name>
    <servlet-class>com.gmustudent.HomePageServlet</servlet-class>
</servlet>
<servlet-mapping>
    <servlet-name>HomePageServlet</servlet-name>
    <url-pattern>/index</url-pattern>
</servlet-mapping>

当我把它放在地址栏中时,我得到了我的主页站点,servlet根据请求抓取了我的所有内容.

http://localhost:8086/gmustudent/index

但是,这给了我一个404

http://localhost:8086/gmustudent/

当没有明确说明索引时,为什么我的欢迎文件列表不会抓取欢迎文件servlet?

解决方法

http://localhost:8086/gmustudent/

gmustudent是web应用程序的上下文根. index是您想要访问的资源.

你配置如下所示的欢迎文件,删除前置/:

<welcome-file>Index</welcome-file> 
</welcome-file-list>

访问

http://localhost:8086/gmustudent/

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读