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

2019-03-06 00:25发布

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条回答
虎瘦雄心在
2楼-- · 2019-03-06 01:06

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.

查看更多
登录 后发表回答