You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Customize Thymeleaf default template resolver order
Currently, the default TemplateResolver had no specific order. Thymeleaf
handles that with a "always first" strategy (that can be confusing if
several TemplateResolver have a "null" order.
While it is a fine default (and changing it could lead to weird side
effects), it has to be changed as soon as another TemplateResolver bean
is defined in the project.
The `spring.thymeleaf.template-resolver-order` property has been added to
control the order of the default TemplateResolver.
Closesspring-projectsgh-3575
Copy file name to clipboardExpand all lines: spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafAutoConfiguration.java
+4
Original file line number
Diff line number
Diff line change
@@ -101,6 +101,10 @@ public TemplateResolver defaultTemplateResolver() {
Copy file name to clipboardExpand all lines: spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafProperties.java
+15
Original file line number
Diff line number
Diff line change
@@ -73,6 +73,13 @@ public class ThymeleafProperties {
73
73
*/
74
74
privatebooleancache = true;
75
75
76
+
/**
77
+
* Order of the template resolver in the chain. By default, the template resolver
78
+
* is first in the chain. Order start at 1 and should only be set if you have
79
+
* defined additional "TemplateResolver" beans.
80
+
*/
81
+
privateIntegertemplateResolverOrder;
82
+
76
83
/**
77
84
* Comma-separated list of view names that can be resolved.
78
85
*/
@@ -152,6 +159,14 @@ public void setCache(boolean cache) {
Copy file name to clipboardExpand all lines: spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafAutoConfigurationTests.java
+13
Original file line number
Diff line number
Diff line change
@@ -51,6 +51,7 @@
51
51
* Tests for {@link ThymeleafAutoConfiguration}.
52
52
*
53
53
* @author Dave Syer
54
+
* @author Stephane Nicoll
54
55
*/
55
56
publicclassThymeleafAutoConfigurationTests {
56
57
@@ -92,6 +93,18 @@ public void overrideCharacterEncoding() throws Exception {
0 commit comments