Skip to content

Commit 314072f

Browse files
committed
Add conditional beans for JSP InternalResourceViewResolver
Signed-off-by: dae won <[email protected]>
1 parent dbfbd97 commit 314072f

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
import org.springframework.boot.autoconfigure.condition.ConditionalOnBooleanProperty;
3939
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
4040
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
41+
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
4142
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
4243
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication.Type;
4344
import org.springframework.boot.autoconfigure.http.HttpMessageConverters;
@@ -139,6 +140,7 @@
139140
* @author Bruce Brouwer
140141
* @author Artsiom Yudovin
141142
* @author Scott Frederick
143+
* @author daewon kim
142144
* @since 2.0.0
143145
*/
144146
@AutoConfiguration(after = { DispatcherServletAutoConfiguration.class, TaskExecutionAutoConfiguration.class,
@@ -282,13 +284,23 @@ public void configureContentNegotiation(ContentNegotiationConfigurer configurer)
282284

283285
@Bean
284286
@ConditionalOnMissingBean
287+
@ConditionalOnProperty(prefix = "spring.mvc.view", name = {"prefix", "suffix"})
285288
public InternalResourceViewResolver defaultViewResolver() {
286289
InternalResourceViewResolver resolver = new InternalResourceViewResolver();
287290
resolver.setPrefix(this.mvcProperties.getView().getPrefix());
288291
resolver.setSuffix(this.mvcProperties.getView().getSuffix());
289292
return resolver;
290293
}
291294

295+
@Bean
296+
@ConditionalOnProperty(prefix = "spring.mvc.jsp", name = {"prefix", "suffix"})
297+
public InternalResourceViewResolver jspViewResolver() {
298+
InternalResourceViewResolver resolver = new InternalResourceViewResolver();
299+
resolver.setPrefix(this.mvcProperties.getJsp().getPrefix());
300+
resolver.setSuffix(this.mvcProperties.getJsp().getSuffix());
301+
return resolver;
302+
}
303+
292304
@Bean
293305
@ConditionalOnBean(View.class)
294306
@ConditionalOnMissingBean

0 commit comments

Comments
 (0)