Skip to content

Commit f70d85c

Browse files
Added configuration parameters at ThymeleafProperties for "fullModeViewNames" and "chunkedModeViewNames"
1 parent 7d5f3a3 commit f70d85c

File tree

3 files changed

+47
-0
lines changed

3 files changed

+47
-0
lines changed

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafAutoConfiguration.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,8 @@ public ThymeleafReactiveViewResolver thymeleafViewResolver(
264264
resolver.setResponseMaxChunkSizeBytes(
265265
this.properties.getReactive().getMaxChunkSize());
266266
}
267+
resolver.setFullModeViewNames(this.properties.getReactive().getFullModeViewNames());
268+
resolver.setChunkedModeViewNames(this.properties.getReactive().getChunkedModeViewNames());
267269
// This resolver acts as a fallback resolver (e.g. like a
268270
// InternalResourceViewResolver) so it needs to have low precedence
269271
resolver.setOrder(Ordered.LOWEST_PRECEDENCE - 5);

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafProperties.java

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,19 @@ public static class Reactive {
227227
*/
228228
private List<MediaType> mediaTypes;
229229

230+
/**
231+
* Comma-separated list of view names (patterns allowed) that should be executed in FULL mode
232+
* even if a max chunk size is set.
233+
*/
234+
private String[] fullModeViewNames;
235+
236+
/**
237+
* Comma-separated list of view names (patterns allowed) that should be the only ones executed
238+
* in CHUNKED mode when a max chunk size is set.
239+
*/
240+
private String[] chunkedModeViewNames;
241+
242+
230243
public List<MediaType> getMediaTypes() {
231244
return this.mediaTypes;
232245
}
@@ -243,6 +256,22 @@ public void setMaxChunkSize(int maxChunkSize) {
243256
this.maxChunkSize = maxChunkSize;
244257
}
245258

259+
public String[] getFullModeViewNames() {
260+
return this.fullModeViewNames;
261+
}
262+
263+
public void setFullModeViewNames(String[] fullModeViewNames) {
264+
this.fullModeViewNames = fullModeViewNames;
265+
}
266+
267+
public String[] getChunkedModeViewNames() {
268+
return this.chunkedModeViewNames;
269+
}
270+
271+
public void setChunkedModeViewNames(String[] chunkedModeViewNames) {
272+
this.chunkedModeViewNames = chunkedModeViewNames;
273+
}
274+
246275
}
247276

248277
}

spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafReactiveAutoConfigurationTests.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,22 @@ public void overrideViewNames() throws Exception {
112112
assertThat(views.getViewNames()).isEqualTo(new String[] { "foo", "bar" });
113113
}
114114

115+
@Test
116+
public void overrideFullModeViewNames() throws Exception {
117+
load(BaseConfiguration.class, "spring.thymeleaf.reactive.fullModeViewNames:foo,bar");
118+
ThymeleafReactiveViewResolver views = this.context
119+
.getBean(ThymeleafReactiveViewResolver.class);
120+
assertThat(views.getFullModeViewNames()).isEqualTo(new String[] { "foo", "bar" });
121+
}
122+
123+
@Test
124+
public void overrideChunkedModeViewNames() throws Exception {
125+
load(BaseConfiguration.class, "spring.thymeleaf.reactive.chunkedModeViewNames:foo,bar");
126+
ThymeleafReactiveViewResolver views = this.context
127+
.getBean(ThymeleafReactiveViewResolver.class);
128+
assertThat(views.getChunkedModeViewNames()).isEqualTo(new String[] { "foo", "bar" });
129+
}
130+
115131
@Test
116132
public void templateLocationDoesNotExist() throws Exception {
117133
load(BaseConfiguration.class,

0 commit comments

Comments
 (0)