cakduro
cakduro

Reputation: 190

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

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?

Upvotes: 0

Views: 891

Answers (1)

maba
maba

Reputation: 48095

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.

Upvotes: 1

Related Questions