jsp - 覆盖 jar META-INF/resources 中的 JSP 文件不可预测

标签 jsp maven resources taglib meta-inf

我正在构建一个模块化的 Web 应用程序,其中有一些 Spring 组件打包在 jar 依赖项(不同的模块)中。该 jar 还包含一些 JSP 资源,例如:

 - Module
     + src/main/resources/META-INF/resources/module/*.jsp

Now I want to override a specific JSP using the following structure in my application.

 - App
     + src/main/resources/META-INF/resources/module/menu.jsp

When running the application using tomcat7:run it will sometimes show the overridden menu.jsp but will any subsequent runs will end up with the old one.

Running with tomcat7:run-war was more promising. Most of the runs the new menu.jsp is shown. But when deploying the application to another Tomcat 7 instance the old menu is visible once again.

The menu.jsp is include using pageContext.include("/module/menu.jsp"); which is called by a custom tag.

How can I make this overriding of resources more reliable? I'm totally clueless since it seems to be randomly working. I hope somebody can shed some light here.


Not sure if this is relevant but to be able to use component scanning I need to unpack the jar classes with the following plugin configuration.

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-dependency-plugin</artifactId>
    <executions>
        <execution>
            <id>unpack</id>
            <phase>process-resources</phase>
            <goals>
                <goal>unpack</goal>
            </goals>
            <configuration>
                <overWriteIfNewer>false</overWriteIfNewer>
                <artifactItems>
                    <artifactItem>
                        <groupId>my.company</groupId>
                        <artifactId>my-dependency</artifactId>
                        <version>1.0-SNAPSHOT</version>
                        <type>jar</type>
                        <outputDirectory>${project.build.directory}/classes</outputDirectory>
                        <includes>**/*.class</includes>
                    </artifactItem>
                </artifactItems>
            </configuration>
        </execution>
    </executions>
</plugin>

最佳答案

经过一番折腾后,我意识到我犯了一个非常简单的错误。我现在搬家了

- App
     + src/main/resources/META-INF/resources/module/menu.jsp

到达地点

- App
     + src/main/webapp/module/menu.jsp

一切都按预期进行。

关于jsp - 覆盖 jar META-INF/resources 中的 JSP 文件不可预测,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24220328/

相关文章:

java - JSP中图片上传问题

jsp - JSP EL 有 eval 函数吗?

jsp - 在 Tomcat 中隐藏 .jsp 扩展名

eclipse - Spring Eclipse(STS)@RequestMapping View 为空,是否由于Maven项目?

javascript - 未能执行 objective-c om.github.eirslett :frontend-maven-plugin:1. 6:install-node-and-npm(安装 Node 和 npm)

Grails: getClass().getResource ("whatever") 不起作用

asp.net - ASP.NET 资源文件中的空格折叠

java - 使用 JSP 表单更新对象

java - 如何解决 Maven 依赖项 "Failed to execute goal on project"的问题

resources - 带有标题 munge 的 puppet 资源命令