[英]Web application with Enunciate: where to put the static resources
I use Enunciate ( http://enunciate.codehaus.org/ ) for our web-service layer and I just want to do something very simple but do not find any documentation. 我将Enunciate( http://enunciate.codehaus.org/ )用于我们的Web服务层,我只想做一些非常简单的事情,但找不到任何文档。
I want to deploy some images and other static resources and to be accessible from eg http://localhost:8080/myapp/images/img01.png
我想部署一些图像和其他静态资源,并可以从例如
http://localhost:8080/myapp/images/img01.png
I tried to create a folder images
under src/main/resources
but it is not deployed like I want (all files/folder inside there goes to myapp/WEB-INF/classes, which as expected). 我试图在
src/main/resources
下创建一个文件夹images
,但是没有按我的意愿进行部署(其中的所有文件/文件夹都进入了myapp / WEB-INF / classes,这与预期的一样)。
Someone can point me where are the static resources with the enunciate project? 有人可以指出我该项目的静态资源在哪里?
I do not have the web.xml as it is automatically generated by the enunciate framework. 我没有web.xml,因为它是由说明性框架自动生成的。
Static resources are structured using the standard project structure of the maven-war-plugin
. 静态资源是使用
maven-war-plugin
的标准项目结构构建的 。 So basically, you just put your image under src/main/webapp/images/img01.png
. 因此,基本上,您只需将图像放在
src/main/webapp/images/img01.png
。
In fact I found how to do it and I publish my solution as an answer 实际上,我找到了解决方法,并发布了解决方案作为答案
In our pom.xml
, we refers the enunciate.xml path like this: 在我们的
pom.xml
,我们像这样引用enunciate.xml路径:
<plugin>
<groupId>org.codehaus.enunciate</groupId>
<artifactId>maven-enunciate-spring-plugin</artifactId>
<version>${enunciate.version}</version>
<configuration>
<configFile>src/conf/enunciate.xml</configFile>
</configuration>
<executions>
<execution>
<goals>
<goal>assemble</goal>
</goals>
</execution>
</executions>
</plugin>
and in the enunciate.xml
file: 并在
enunciate.xml
文件中:
<webapp postBase="web"></webapp>
which means the static resources can be put in src/conf/web/
and then my folder called images
will simply located in: src/conf/web/images
. 这意味着可以将静态资源放在
src/conf/web/
,然后将我的名为images
文件夹简单地放在src/conf/web/images
。
Like this all these static resources will be accessible by http://localhost:8080/myappcontext/images/
这样,所有这些静态资源都可以通过
http://localhost:8080/myappcontext/images/
The enunciate documentation shows the option available for the webapp element: 清晰的文档显示了可用于webapp元素的选项:
For the images and other static resources there should not be any difference using one of these attributes. 对于图像和其他静态资源,使用这些属性之一应该没有任何区别。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.