aime
aime

Reputation: 247

Proper folders structure for web application

I have a question - I created a war-package of the web-application (using Maven). The archive includes everything excepting jsp-files and resources. I know that Maven tracks only src/main/resorces and the proper solution is to keep jsp/css/xml in this directory. I develop in IntellijIdea and it has another folders structure for web-application. All the java-files are stored under src/main/java and jsp/css/xml are under web/resources and web/WEB-INF.

The question is where I have to store all resource files when developing? The idea to put them under src/main/resorces doesn't seem to me elegant because default folders structures is dislocated. I hope that I described my problem intelligibly. Thank you for reply

(I can't attach screenshot because of reputation shortage, so here it is a link enter link description here)

Upvotes: 0

Views: 2389

Answers (2)

Cristian Sevescu
Cristian Sevescu

Reputation: 1489

I am not sure why you find the src/main/resources path as inelegant. This is the default path for maven.

For web applications src/main/webapp is also used and you can put the jsp,html,... files there.

If you have another structure you can configure maven to take web resources from another path as well.

<build>
<plugins>
  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-war-plugin</artifactId>
    <version>2.6</version>
    <configuration>
      <webResources>
        <resource>
          <!-- this is relative to the pom.xml directory -->
          <directory>resource2</directory>
        </resource>
      </webResources>
    </configuration>
  </plugin>
</plugins>

Examples here clarify the structure well enough.

Upvotes: 0

Alex
Alex

Reputation: 2485

You want src/main/webapp for static web resources (HTML, CSS, JS, etc.)

See http://maven.apache.org/guides/introduction/introduction-to-the-standard-directory-layout.html

Upvotes: 1

Related Questions