【问题标题】:welcome file configuration alternative to web.xml欢迎文件配置替代 web.xml
【发布时间】:2015-03-21 04:32:21
【问题描述】:

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

背景:

10.10 欢迎文件

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

Java Servlet 规范版本 3.0 Rev a 2010 年 12 月

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

另见:

https://stackoverflow.com/a/19317470/262852

更新:

我补充说:

<?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>

作为web.xml,它工作正常——但希望在没有xml 的情况下完成相同的结果。

【问题讨论】:

    标签: jsp jakarta-ee servlets netbeans web.xml


    【解决方案1】:

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

    如您所见,没有特殊的注解来定义welcome-file列表,也请参考这个答案here

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

    如果您在 tomcat 服务器上,还请检查此答案 here

    希望对你有帮助

    【讨论】:

      猜你喜欢
      • 2013-01-16
      • 1970-01-01
      • 2013-04-17
      • 1970-01-01
      • 2012-05-01
      • 2019-03-28
      • 2014-01-15
      • 2013-03-27
      • 1970-01-01
      相关资源
      最近更新 更多