我正在尝试使用tomcat7-maven-plugin显示位于我的应用程序外部的某个文件夹中的图像。我遇到了这篇文章:https://howtoprogramwithjava.com/how-to-display-images-stored-on-a-server/据说有一种方法是在目录中创建一个xml文件来定义上下文路径。但是,我使用的是tomcat7-maven-plugin,所以我找不到其中指定的位置。如果可能的话,我不知道如何在pom.xml中配置它。提前感谢大家!
发布于 2018-01-05 19:32:43
在webapp/META-INF文件夹中可以有一个context.xml文件,如下所示
src
main
webapp
META-INF
context.xml
WEB-INF你想要的内容。
或者,您可以将allowLinking属性添加到Context部分,然后在webapp文件夹中使用ln -s命令创建指向图像文件夹的软链接。
如果要将资源打包到应用程序war,可将其指定为web资源
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<webResources>
<resource>
<!-- this is relative to the pom.xml directory where can find your images -->
<directory>${project.basedir}/src/main/resources
</directory>
</resource>
</webResources>
<warName>yourwarname</warName>
</configuration>
</plugin>
</plugins>
</build>https://stackoverflow.com/questions/48112434
复制相似问题