0

I noticed that applications generated by jHipster serve almost all file content available from the WAR artifact. For example, if there is a file README.MD next to index.html, it can be accessed via http://localhost:8080/README.MD.

The only files that aren't served are those files within the META-INF/ and WEB-INF/ directories.

Where does a jHipster application's source code configure to serve arbitrary files but not files from META-INF/** and META-INF/**?

Abdull
  • 26,371
  • 26
  • 130
  • 172

1 Answers1

3

There is no configuration at all, it's part of the Servlet specification: both of those directories are secured by the servlet container, without doing anything specific.

You might be confused because many people store their files in WEB-INF, for example WEB-INF/jsp/ for the JSP files. People do this to protect those files from being accessed directly, and have a Controller (like a Spring MVC controller or Struts controller) that redirects to those pages once it has processed the request.

JHipster works differently, as it only has static pages that do REST requests to the back-end, so it's a different architecture.

Julien Dubois
  • 3,678
  • 1
  • 20
  • 22
  • It's serving what is inside `src/main/webapp` in your project, which is the standard Maven directory for this. – Julien Dubois Jul 19 '16 at 09:28
  • @JulienDubios, thanks! I found the relevant code in `WebMvcAutoConfigurationAdapter.addResourceHandlers(ResourceHandlerRegistry)` in conjunction with the `@ConfigurationProperties` properties sources `ResourceProperties` and `WebMvcProperties`. [It is also mentioned in the Spring Boot documentation](http://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-developing-web-applications.html#boot-features-spring-mvc-static-content), albeit subtly ("*Spring Boot will serve static content [...] from the root of the ServletContext.*"). – Abdull Jul 19 '16 at 15:44