1. What is Thymeleaf
Thymeleaf is a template engine for Java-based applications. It allows you to include special attributes and tags in HTML, XML or JavaScript files and handle dynamic data processing and rendering. Spring Boot uses auto-configuration to integrate the application with Thymeleaf engine and provides common property values that should work without changing in most cases/applications.
2. Thymeleaf Spring Boot default properties
Spring Boot provides default configuration for Thymeleaf engine. To change common values we need to override property in configuration file: application.properties
or application.yml
.
The default Thymeleaf properties has the following values:
1) Whether to enable template caching
Default value is true
, set to false if you want templates to be automatically updated when modified.
spring.thymeleaf.cache=true
2) Whether to check that the template exists before rendering it
spring.thymeleaf.check-template=true
3) Whether to check that the templates location exists
spring.thymeleaf.check-template-location=true
4) Whether to enable Thymeleaf view resolution for Web frameworks
spring.thymeleaf.enabled=true
5) Enable the SpringEL compiler in SpringEL expressions.
spring.thymeleaf.enable-spring-el-compiler=false
6) Template files encoding.
spring.thymeleaf.encoding=UTF-8
7) Comma-separated list of view names (patterns allowed) that should be excluded from resolution.
spring.thymeleaf.excluded-view-names=
8) Template mode to be applied to templates. See also Thymeleaf's TemplateMode enum.
spring.thymeleaf.mode=HTML
9) Prefix that gets prepended to view names when building a URL.
spring.thymeleaf.prefix=classpath:/templates/
10) Comma-separated list of view names (patterns allowed) that should be the only ones executed in CHUNKED mode when a max chunk size is set.
spring.thymeleaf.reactive.chunked-mode-view-names=
11) Comma-separated list of view names (patterns allowed) that should be executed in FULL mode even if a max chunk size is set.
spring.thymeleaf.reactive.full-mode-view-names=
12) Maximum size of data buffers used for writing to the response.
spring.thymeleaf.reactive.max-chunk-size=0B
13) Media types supported by the view technology.
spring.thymeleaf.reactive.media-types=
14) Whether hidden form inputs acting as markers for checkboxes should be rendered before the checkbox element itself.
spring.thymeleaf.render-hidden-markers-before-checkboxes=false
15) Content-Type value written to HTTP responses.
spring.thymeleaf.servlet.content-type=text/html
16) Whether Thymeleaf should start writing partial output as soon as possible or buffer until template processing is finished.
spring.thymeleaf.servlet.produce-partial-output-while-processing=true
17) Suffix that gets appended to view names when building a URL.
spring.thymeleaf.suffix=.html
18) Order of the template resolver in the chain.
spring.thymeleaf.template-resolver-order=
19) Comma-separated list of view names (patterns allowed) that can be resolved.
spring.thymeleaf.view-names=
{{ 'Comments (%count%)' | trans {count:count} }}
{{ 'Comments are closed.' | trans }}