Make maven serve files like css.gz and js.gz

烂漫一生 提交于 2019-12-31 05:07:11

问题


I have manually compressed my CSS using manual gzip and I'm trying to include css.gz from external source.

<link rel="stylesheet" href="<c:url value="/resources/css/style.css.gz"/>" type="text/css" media="screen" />

It is simple and works well when I'm using PHP and Apache.

The problem is, I'm now working with a Java EE project using spring and Apache Maven.

So, how to configure maven to know about precompressed files like that?


回答1:


You should create a source structure like the following:

.
├── pom.xml
└── src
    └── main
        ├── java
        ├── resources
        └── webapp
            ├── WEB-INF
            └── resources
                └── css
                    └── style.css.gz

The src/main/java will contain all your java code.

The src/main/resources/ should contain resources used by your application and that should not be publicly available. For example Resource Bundles, property files etc.

The src/main/webapp/ will contain your web application specific files.

Also make sure that the <packaging>war</packaging> tag is added to your pom.



来源:https://stackoverflow.com/questions/12668970/make-maven-serve-files-like-css-gz-and-js-gz

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!