简体   繁体   English

具有Enunciate的Web应用程序:放置静态资源的位置

[英]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元素的选项:

  • preBase is a folder or zipped archive which will be copied before the enunciate generation preBase是一个文件夹或压缩的归档文件,将在说明生成之前复制
  • postBase is a folder of zipped archive which will be copied after the enunciate generation postBase是压缩档案的文件夹,在生成后会复制该文件夹

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM