Reinstate support for Thymeleaf

This commit is contained in:
Andy Wilkinson
2022-01-06 13:28:05 +00:00
parent e95f038c01
commit 12cd97a20c
60 changed files with 2304 additions and 30 deletions

View File

@@ -674,6 +674,8 @@ howto-change-the-user-details-service-and-add-user-accounts=howto.security.chang
howto-enable-https=howto.security.enable-https
howto-hotswapping=howto.hotswapping
howto-reload-static-content=howto.hotswapping.reload-static-content
howto-reload-thymeleaf-template-content=howto.hotswapping.reload-templates
howto-reload-thymeleaf-content=howto.hotswapping.reload-templates.thymeleaf
howto-reload-freemarker-content=howto.hotswapping.reload-templates.freemarker
howto-reload-groovy-template-content=howto.hotswapping.reload-templates.groovy
howto-reload-fast-restart=howto.hotswapping.fast-application-restarts

View File

@@ -30,6 +30,13 @@ If you use the `spring-boot-devtools` module, these properties are <<using#using
[[howto.hotswapping.reload-templates.thymeleaf]]
==== Thymeleaf Templates
If you use Thymeleaf, set `spring.thymeleaf.cache` to `false`.
See {spring-boot-autoconfigure-module-code}/thymeleaf/ThymeleafAutoConfiguration.java[`ThymeleafAutoConfiguration`] for other Thymeleaf customization options.
[[howto.hotswapping.reload-templates.freemarker]]
==== FreeMarker Templates
If you use FreeMarker, set `spring.freemarker.cache` to `false`.

View File

@@ -203,6 +203,11 @@ If you add your own, you have to be aware of the order and in which position you
This is a composite resolver, delegating to all the others and attempting to find a match to the '`Accept`' HTTP header sent by the client.
There is a useful https://spring.io/blog/2013/06/03/content-negotiation-using-views[blog about `ContentNegotiatingViewResolver`] that you might like to study to learn more, and you might also look at the source code for detail.
You can switch off the auto-configured `ContentNegotiatingViewResolver` by defining a bean named '`viewResolver`'.
* If you use Thymeleaf, you also have a `ThymeleafViewResolver` named '`thymeleafViewResolver`'.
It looks for resources by surrounding the view name with a prefix and suffix.
The prefix is `spring.thymeleaf.prefix`, and the suffix is `spring.thymeleaf.suffix`.
The values of the prefix and suffix default to '`classpath:/templates/`' and '`.html`', respectively.
You can override `ThymeleafViewResolver` by providing a bean of the same name.
* If you use FreeMarker, you also have a `FreeMarkerViewResolver` named '`freeMarkerViewResolver`'.
It looks for resources in a loader path (which is externalized to `spring.freemarker.templateLoaderPath` and has a default value of '`classpath:/templates/`') by surrounding the view name with a prefix and a suffix.
The prefix is externalized to `spring.freemarker.prefix`, and the suffix is externalized to `spring.freemarker.suffix`.
@@ -221,5 +226,6 @@ If you add your own, you have to be aware of the order and in which position you
For more detail, see the following sections:
* {spring-boot-autoconfigure-module-code}/web/servlet/WebMvcAutoConfiguration.java[`WebMvcAutoConfiguration`]
* {spring-boot-autoconfigure-module-code}/thymeleaf/ThymeleafAutoConfiguration.java[`ThymeleafAutoConfiguration`]
* {spring-boot-autoconfigure-module-code}/freemarker/FreeMarkerAutoConfiguration.java[`FreeMarkerAutoConfiguration`]
* {spring-boot-autoconfigure-module-code}/groovy/template/GroovyTemplateAutoConfiguration.java[`GroovyTemplateAutoConfiguration`]

View File

@@ -50,6 +50,7 @@ While caching is very beneficial in production, it can be counter-productive dur
For this reason, spring-boot-devtools disables the caching options by default.
Cache options are usually configured by settings in your `application.properties` file.
For example, Thymeleaf offers the configprop:spring.thymeleaf.cache[] property.
Rather than needing to set these properties manually, the `spring-boot-devtools` module automatically applies sensible development-time configuration.
Because you need more information about web requests while developing Spring MVC and Spring WebFlux applications, developer tools suggests you to enable `DEBUG` logging for the `web` logging group.

View File

@@ -141,6 +141,7 @@ Spring WebFlux supports a variety of templating technologies, including Thymelea
Spring Boot includes auto-configuration support for the following templating engines:
* https://freemarker.apache.org/docs/[FreeMarker]
* https://www.thymeleaf.org[Thymeleaf]
* https://mustache.github.io/[Mustache]
When you use one of these templating engines with the default configuration, your templates are picked up automatically from `src/main/resources/templates`.

View File

@@ -308,6 +308,7 @@ Spring Boot includes auto-configuration support for the following templating eng
* https://freemarker.apache.org/docs/[FreeMarker]
* https://docs.groovy-lang.org/docs/next/html/documentation/template-engines.html#_the_markuptemplateengine[Groovy]
* https://www.thymeleaf.org[Thymeleaf]
* https://mustache.github.io/[Mustache]
TIP: If possible, JSPs should be avoided.