欢迎文件配置替代 web.xml

Thu*_*fir 3 jsp netbeans web.xml servlets jakarta-ee

没有的情况下web.xml,欢迎文件配置在哪里?

背景:

10.10 欢迎文件

Web 应用程序开发人员可以在 Web 应用程序部署描述符中定义称为欢迎文件的部分 URI 的有序列表。

Java Servlet 规范版本 3.0 修订版 2010 年 12 月

我正在使用 Netbeans 8,但没有意识到web.xml现在的职责主要是通过注释完成的。但是,我似乎找不到与欢迎文件相关的注释。目前,index.html负载,我想将其重新配置为foo.jsp. 可以在不创建文件的情况下完成此操作吗web.xml

也可以看看:

/sf/answers/1352222931/

更新:

我补充道:

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.1" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd">
    <session-config>
        <session-timeout>
            30
        </session-timeout>
    </session-config>
    <welcome-file-list>
        <welcome-file>foo.jsp</welcome-file>
    </welcome-file-list>
</web-app>
Run Code Online (Sandbox Code Playgroud)

asweb.xml并且它工作得很好 - 但希望在没有xml.

小智 5

在Servlet 3.0中,定义了几个新的注释。这些注释位于javax.servlet.annotation包中。

正如你所看到的,没有特殊的注释来定义欢迎文件列表,也请参考这里的答案

但请在此处检查以下答案,因为它描述了一种解决方法,可以让您的欢迎文件将其重新配置为 foo.jsp 。

如果您使用的是tomcat服务器,也请在此处查看此答案。

希望有帮助