maven webapp将jsps放在/ WEB-INF/jsp中

Jac*_*ine 7 java maven-2 web-applications

我继承了使用NetBean的内部ant构建的webapp.

所有jsps都位于:

WEB-INF/jsp
Run Code Online (Sandbox Code Playgroud)

web.xml包含指向/WEB-INF/jsp/somefile.jsp的硬编码链接

如何使用maven war插件将JSP放在那里,保持与当前结构的一致性?

我的pom目前写道:

<warSourceDirectory>${basedir}/web/WEB-INF</warSourceDirectory>
Run Code Online (Sandbox Code Playgroud)

Pas*_*ent 12

有什么问题?让我们看一下标准的战争项目结构:

$ mvn archetype:create -DgroupId=com.mycompany.app \
> -DartifactId=my-webapp -DarchetypeArtifactId=maven-archetype-webapp
...
$ tree my-webapp/
my-webapp/
|-- pom.xml
`-- src
    `-- main
        |-- resources
        `-- webapp
            |-- WEB-INF
            |   `-- web.xml
            `-- index.jsp

5 directories, 3 files 

无需配置任何东西,只需将JSP放在下面src/main/webapp/WEB-INF/jsp即可.

编辑:我不明白为什么你的maven-war-plugin配置中有以下行:

<warSourceDirectory>${basedir}/web/WEB-INF</warSourceDirectory>
Run Code Online (Sandbox Code Playgroud)

预期的行为是什么?你为什么不使用默认值${basedir}/src/main/webapp