Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/389.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何在eclipse中更改默认启动页面?_Java_Xml_Eclipse_Jsp - Fatal编程技术网

Java 如何在eclipse中更改默认启动页面?

Java 如何在eclipse中更改默认启动页面?,java,xml,eclipse,jsp,Java,Xml,Eclipse,Jsp,您好,我正在尝试将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/java

您好,我正在尝试将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>

解密
index.html
index.htm
index.jsp
default.html
default.htm
default.jsp
**welcome.jsp**

我编辑了欢迎文件列表,并向其中添加了
welcome.jsp
。但它仍然不起作用。任何帮助都将不胜感激

列出
条目的顺序很重要,因为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>

welcome.jsp
index.html
index.htm
index.jsp
default.html
default.htm
default.jsp

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

正如Ravi所说,web.xml中的文件顺序很重要 所以,如果您希望显示welcome.jsp,请将此条目保留为中的第一行
标签

此外,并非所有文件都必须包含,如index.html、index.htm、index.jsp。。。。etc位于
标签下。如果您知道您的主页,那么您只能添加一个jsp,如下所示

<welcome-file-list>
  <welcome-file>welcome.jsp</welcome-file>
</welcome-file-list>

welcome.jsp
注意: 此外,建议您将jsp放在web inf文件夹下。
有关详细信息,请参阅

不,这对我不起作用。同样的事情正在发生,它正在显示目录列表。您在浏览器中使用的确切URL是什么。。解密是项目名称。我正在eclipse上运行这个东西,默认浏览器正在访问这个URL,你会得到一个
/
的目录列表,也就是说,你是否看到
/welcome.jsp
作为文件之一?你能验证
web.xml
tomcat\u install\u dir/webapps/Decryption/web-INF/web.xml
中是否有你正在做的更改吗?