【问题标题】:strange behavior by position of welcome page in maven dynamic web projectMaven 动态 Web 项目中欢迎页面位置的奇怪行为
【发布时间】:2014-02-13 06:08:36
【问题描述】:

我使用 maven 创建了一个 web 项目:

mvn archetype:generate -DgroupId=com.test -DartifactId=ioehr -DarchetypeArtifactId=maven-archetype-webapp -DinteractiveMode=false

然后在eclipse中导入项目并修改web.xml文件添加欢迎文件入口为:

<web-app>
    <display-name>test</display-name>
    <welcome-file-list>
        <welcome-file>index.jsp</welcome-file>
    </welcome-file-list>
</web-app>

默认情况下这是项目结构

--src
-----main
---------webapp
---------------WEB-INF
----------------------web.xml
---------------index.jsp
--WebContent
-----WEB-INF
------------lib
------------web.xml
-----pom.xml

然后尝试在服务器上运行项目。它给了我例外 请求的资源 (/test/) 不可用。

当我将 index.jsp 移动到 WebContent 文件夹时,它会显示欢迎页面。

我的问题是,为什么我需要手动将 index.jsp 移动到 WebContent 文件夹中。 为什么它在 webapp 文件夹中不起作用

【问题讨论】:

    标签: java eclipse jsp maven web.xml


    【解决方案1】:

    Eclipse 默认从WebContent 文件夹中提供文件。当您将 index.jsp 移动到 WebContent 时,Eclipse 找到了它并将其返回。

    您可以将WebContent 的位置更改为指向您的项目内容,如下所述:How do I change in an eclipse web project the WebContent folder to something different?

    【讨论】:

      猜你喜欢
      • 2017-01-09
      • 2015-06-22
      • 2017-11-30
      • 1970-01-01
      • 2018-11-28
      • 2023-03-28
      • 1970-01-01
      • 2013-03-06
      • 2012-09-04
      相关资源
      最近更新 更多