MarcGiffing / wicket-spring-boot

Spring Boot starter for Apache Wicket
151 stars 61 forks source link

Missing documentation on where to put static resources while using wicket with spring boot (jar) #180

Closed piroMe closed 2 years ago

piroMe commented 3 years ago

So, I was banging my head against the wall for almost a day on WHERE TO PUT STATIC RESOURCES SO THAT THEY WOULD BE ACCESSIBLE TO APP AT STARTUP WHILE USING spring boot + wicket (jar) and after searching / browosing / testing / bruteforcing I've found an entry on

https://www.baeldung.com/spring-mvc-static-resources

to sum up (excerpt)

_Spring Boot comes with a pre-configured implementation of ResourceHttpRequestHandler to facilitate serving static resources.

By default, this handler serves static content from any of /static, /public, /resources, and /META-INF/resources directories that are on the classpath. Since src/main/resources is typically on the classpath by default, we can place any of these directories there.

For example, if we put an about.html file inside the /static directory in our classpath, then we can access that file via http://localhost:8080/about.html. Similarly, we can achieve the same result by adding that file in other mentioned directories._

By default, Spring Boot serves all static content under the root part of the request, that is, /**. Even though it seems to be a good default configuration, we can change it via the spring.mvc.static-path-pattern configuration property.

For example, if we want to access the same file via http://localhost:8080/content/about.html, we can say so in our application.properties:

spring.mvc.static-path-pattern=/content/** In WebFlux environments, we should use the spring.webflux.static-path-pattern property.

_2.2. Custom Directories

Similar to path patterns, it's also possible to change the default resource locations via the spring.resources.static-locations configuration property. This property can accept multiple comma-separated resource locations:

spring.resources.static-locations=classpath:/files/,classpath:/static-files Here, we're serving static contents from the /files and /static-files directories inside the classpath. Moreover, Spring Boot can serve static files from outside of the classpath:

spring.resources.static-locations=file:/opt/files Here we're using the file resource signature, file:/, to serve files from our local disk._

Could you be so kind and include this piece of information in your readme?

martin-g commented 3 years ago

Hi,

All this is Spring Boot specific. I remember reading it in their documentation few years ago. If you believe they should make it easier to find in their docs then you should open a ticket in their GitHub repo.