简体   繁体   中英

What is the best practice of the directory Structure Of Java Web Application

For the WEB-INF folder, it will only store the files that are not accessible to the public. So it will be only index.html stay outside of the WEB-INF folder? For example, like the login and register jsp file should stay inside or outside the WEB-INF folder?

As you said, the WEB-INF content will not be accessible when the web is deployed. Commonly this folder store web low level settings . Also when the app is deployed (classic war on tomcat) this folder WEB-INF has a folder called lib with all the jar libraries.

Any other static asset like, html, css, font, js, etc should be outside of WEB-INF

Just the dynamic content like.jsp should be inside of WEB-INF

Take a look to this maven structure :

在此处输入图像描述

or this in which we can see the classic web.xml

在此处输入图像描述

or this with spring-boot

./pom.xml
./src
./src/main
./src/main/webapp
./src/main/webapp/WEB-INF
./src/main/webapp/WEB-INF/jsp
./src/main/webapp/WEB-INF/jsp/hello.jsp
./src/main/resources
./src/main/resources/application.properties
./src/main/java
./src/main/java/com
./src/main/java/com/
./src/main/java/com/examples
./src/main/java/com/examples/spring
./src/main/java/com/examples/spring/springbootjsp
./src/main/java/com/examples/spring/springbootjsp/controllers
./src/main/java/com/examples/spring/springbootjsp/controllers/HelloController.java
./src/main/java/com/examples/spring/springbootjsp/SpringBootJspApplication.java

I advice you:

  • Use a maven structure for your java web app
  • Use spring

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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