首页 > 解决方案 > 在 intellij 中运行 tomcat 时,Java servlet 找不到我的 index.jsp

问题描述

我使用intellij。

好的,tomcat 正在运行,一切正常,但是离开给我一个 404 错误。

我的 web.xml 位于项目根目录的 webcontent 文件夹中。项目文件夹/WebContent/WEB-INF

<web-app 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_4_0.xsd" version="4.0">

<display-name>WebTicket</display-name>

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

我的页面位于:projectfolder/WebContent

那么在项目属性中,项目方面是 web。

我使用 servle + maven。

任何 Ideia 如何解决它?

问题可能出在文件夹结构中,如果更改项目方面应该解决,我在某处读过,但是该怎么做呢?

标签: javamavenservletsintellij-idea

解决方案


出色地。我将项目创建为 Dynamic Web Module 到 2.5 并更改为 4.0

2.5中Web资源的默认文件夹是projectfolder/src/main/webapp

在 4.0 中是 projectfolder/WebContent

当我在 Eclipse 中更改项目属性中的方面时,旧配置仍然存在。

在intellij中只需进入文件>项目结构

facets 选项卡,选择 Web 模块并更改 Web Resources 文件夹。


推荐阅读