Resource handler configuration¶
Resource handler configuration in Spring Boot defines how static resources are served and mapped within the application^[600-developer-java-spring-thymeleaf-spring-thymeleaf-01.md]. This configuration is managed through the ResourceProperties class and the WebMvcAutoConfiguration, which set up default static locations and cache control headers^[600-developer-java-spring-thymeleaf-spring-thymeleaf-01.md].
Static Resource Locations¶
By default, Spring Boot serves static content from specific classpath locations^[600-developer-java-spring-thymeleaf-spring-thymeleaf-01.md]. These locations are checked in the following order:
classpath:/META-INF/resources/classpath:/resources/classpath:/static/classpath:/public/^[600-developer-java-spring-thymeleaf-spring-thymeleaf-01.md]
WebJars Support¶
The configuration automatically includes support for WebJars, which are client-side dependencies packaged as JAR files^[600-developer-java-spring-thymeleaf-spring-thymeleaf-01.md]. This is implemented by adding a resource handler mapping for the /webjars/** URL pattern to the classpath:/META-INF/resources/webjars/ location^[600-developer-java-spring-thymeleaf-spring-thymeleaf-01.md].
Cache Configuration¶
Resource handlers are configured with specific cache periods and HTTP cache control settings derived from the ResourceProperties^[600-developer-java-spring-thymeleaf-spring-thymeleaf-01.md].
Related Concepts¶
- [[Thymeleaf]]
- Spring Boot
Sources¶
600-developer-java-spring-thymeleaf-spring-thymeleaf-01.md