您好,我正在尝试将eclipse中动态项目的默认起始页面从index.jsp更改为welcome.jsp。我已经在网上浏览了一些答案,并相应地更改了欢迎文件列表,但它仍然不起作用。
我的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/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
<display-name>Decryption</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>
**<welcome-file>welcome.jsp</welcome-file>**
</welcome-file-list>
</web-app>我已经编辑了欢迎文件列表,并将<welcome-file>welcome.jsp</welcome-file>添加到其中。但它仍然不起作用。任何帮助都将不胜感激。
发布于 2015-01-19 16:17:50
列出<welcome-file-list>条目的顺序很重要,因为web容器从上到下查看此列表,并在第一个匹配项处停止搜索。
因此,如果您的web内容目录包含前面列出的另一个文件,如index.jsp,则不会提供welcome.jsp。因此,只需将条目移到顶部就可以解决您的问题。
<welcome-file-list>
<welcome-file>welcome.jsp</welcome-file>
<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>
</welcome-file-list>顺便说一句,您也可以选择删除所有其他条目,只保留指向您的索引文件的条目。列出所有条目不是必需的。
发布于 2015-01-19 16:28:20
正如Ravi所说,web.xml中文件的顺序很重要,所以如果您想要显示welcome.jsp,请将此条目保留为<welcome-file-list>标记中的第一行。
也不是强制性的所有文件,如index.html,index.htm,index.jsp……等在<welcome-file-list>标签下。如果你知道你的主页,那么你只能添加一个jsp,如下所示。
<welcome-file-list>
<welcome-file>welcome.jsp</welcome-file>
</welcome-file-list>注意:也是一个建议,你应该把你的jsp放在web文件夹下。有关详情,请参阅URL
https://stackoverflow.com/questions/28019907
复制相似问题