diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafAutoConfiguration.java index 39e72f6fec..82fc1f6538 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafAutoConfiguration.java @@ -264,6 +264,8 @@ public class ThymeleafAutoConfiguration { resolver.setResponseMaxChunkSizeBytes( this.properties.getReactive().getMaxChunkSize()); } + resolver.setFullModeViewNames(this.properties.getReactive().getFullModeViewNames()); + resolver.setChunkedModeViewNames(this.properties.getReactive().getChunkedModeViewNames()); // This resolver acts as a fallback resolver (e.g. like a // InternalResourceViewResolver) so it needs to have low precedence resolver.setOrder(Ordered.LOWEST_PRECEDENCE - 5); diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafProperties.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafProperties.java index e403f505b6..727dc098c2 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafProperties.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafProperties.java @@ -227,6 +227,19 @@ public class ThymeleafProperties { */ private List mediaTypes; + /** + * Comma-separated list of view names (patterns allowed) that should be executed in FULL mode + * even if a max chunk size is set. + */ + private String[] fullModeViewNames; + + /** + * 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. + */ + private String[] chunkedModeViewNames; + + public List getMediaTypes() { return this.mediaTypes; } @@ -243,6 +256,22 @@ public class ThymeleafProperties { this.maxChunkSize = maxChunkSize; } + public String[] getFullModeViewNames() { + return this.fullModeViewNames; + } + + public void setFullModeViewNames(String[] fullModeViewNames) { + this.fullModeViewNames = fullModeViewNames; + } + + public String[] getChunkedModeViewNames() { + return this.chunkedModeViewNames; + } + + public void setChunkedModeViewNames(String[] chunkedModeViewNames) { + this.chunkedModeViewNames = chunkedModeViewNames; + } + } } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafReactiveAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafReactiveAutoConfigurationTests.java index 7ebe9d4dcd..c2b5fe75f4 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafReactiveAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafReactiveAutoConfigurationTests.java @@ -112,6 +112,22 @@ public class ThymeleafReactiveAutoConfigurationTests { assertThat(views.getViewNames()).isEqualTo(new String[] { "foo", "bar" }); } + @Test + public void overrideFullModeViewNames() throws Exception { + load(BaseConfiguration.class, "spring.thymeleaf.reactive.fullModeViewNames:foo,bar"); + ThymeleafReactiveViewResolver views = this.context + .getBean(ThymeleafReactiveViewResolver.class); + assertThat(views.getFullModeViewNames()).isEqualTo(new String[] { "foo", "bar" }); + } + + @Test + public void overrideChunkedModeViewNames() throws Exception { + load(BaseConfiguration.class, "spring.thymeleaf.reactive.chunkedModeViewNames:foo,bar"); + ThymeleafReactiveViewResolver views = this.context + .getBean(ThymeleafReactiveViewResolver.class); + assertThat(views.getChunkedModeViewNames()).isEqualTo(new String[] { "foo", "bar" }); + } + @Test public void templateLocationDoesNotExist() throws Exception { load(BaseConfiguration.class,