Java index.jsp不显示为初始页面
我正在创建一个JavaRESTWeb服务。出于某种原因,startup page index.jsp给了我一个HTTP状态404-Not Found错误。My index.jsp位于web文件夹中。My web.xml包含Java index.jsp不显示为初始页面,java,jsp,jersey,Java,Jsp,Jersey,我正在创建一个JavaRESTWeb服务。出于某种原因,startup page index.jsp给了我一个HTTP状态404-Not Found错误。My index.jsp位于web文件夹中。My web.xml包含 <welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list> index.jsp 它还包含 <servlet-mapp
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
index.jsp
它还包含
<servlet-mapping>
<servlet-name>Jersey</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
运动衫
/*
我注意到,当我删除servlet映射时,索引页面就工作了。但我需要那个映射。我一直在读类似的帖子,但找不到我问题的答案。非常感谢您的帮助。多谢各位 初始页面应始终为index.html而不是index.jsp。另外,将对index.jsp的引用替换为index.html。它会起作用的。加载index.html页面时,您可以将其重定向到您喜欢的任何页面。Glassfish或Tomcat服务器总是先查找并加载它。将您的web.xml文件设置为如下所示 这件事就是这样:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaeehttp://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
此行包含您的项目名称
<display-name>Project name</display-name>
项目名称
这是您的欢迎文件列表
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
index.html
index.htm
index.jsp
default.html
default.htm
default.jsp
Servlet映射
<servlet-mapping>
<servlet-name>Login</servlet-name>
<url-pattern>/Login</url-pattern>
登录
/登录
在这里,您需要删除servlet映射中的*
更改映射代码
<servlet-mapping>
<servlet-name>Jersey</servlet-name>
<url-pattern>/Jersey</url-pattern>
运动衫
/泽西
我也试过了,但没用。它仅在删除servlet映射时起作用。它可能很小,因为我不是java大师。你的回答不起作用,但它帮助了我。我添加了/Jersey/*。所以我不得不在url中添加一个*但有另一部分。然后,我的索引页可以正常工作,web服务也可以正常工作(但url中有一个额外的部分),我可以接受这一点,但不确定是否可以消除这一部分。再次感谢。