首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何更改eclipse中的默认启动页面?

如何更改eclipse中的默认启动页面?
EN

Stack Overflow用户
提问于 2015-01-19 15:39:20
回答 2查看 2.9K关注 0票数 0

您好,我正在尝试将eclipse中动态项目的默认起始页面从index.jsp更改为welcome.jsp。我已经在网上浏览了一些答案,并相应地更改了欢迎文件列表,但它仍然不起作用。

我的web.xml是这样的:

代码语言:javascript
复制
<?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>添加到其中。但它仍然不起作用。任何帮助都将不胜感激。

EN

回答 2

Stack Overflow用户

发布于 2015-01-19 16:17:50

列出<welcome-file-list>条目的顺序很重要,因为web容器从上到下查看此列表,并在第一个匹配项处停止搜索。

因此,如果您的web内容目录包含前面列出的另一个文件,如index.jsp,则不会提供welcome.jsp。因此,只需将条目移到顶部就可以解决您的问题。

代码语言:javascript
复制
<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>

顺便说一句,您也可以选择删除所有其他条目,只保留指向您的索引文件的条目。列出所有条目不是必需的。

票数 0
EN

Stack Overflow用户

发布于 2015-01-19 16:28:20

正如Ravi所说,web.xml中文件的顺序很重要,所以如果您想要显示welcome.jsp,请将此条目保留为<welcome-file-list>标记中的第一行。

也不是强制性的所有文件,如index.html,index.htm,index.jsp……等在<welcome-file-list>标签下。如果你知道你的主页,那么你只能添加一个jsp,如下所示。

代码语言:javascript
复制
<welcome-file-list>
  <welcome-file>welcome.jsp</welcome-file>
</welcome-file-list>

注意:也是一个建议,你应该把你的jsp放在web文件夹下。有关详情,请参阅URL

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/28019907

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档