Commit 923f286a authored by Dave Syer's avatar Dave Syer

Add spring.view.{prefix,suffix} properties

Fixes #62
parent c661a74c
......@@ -28,6 +28,7 @@ import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.ListableBeanFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
......@@ -110,6 +111,12 @@ public class WebMvcAutoConfiguration {
private static Log logger = LogFactory.getLog(WebMvcConfigurerAdapter.class);
@Value("${spring.view.prefix:}")
private String prefix = "";
@Value("${spring.view.suffix:}")
private String suffix = "";
@Autowired
private ListableBeanFactory beanFactory;
......@@ -117,10 +124,11 @@ public class WebMvcAutoConfiguration {
private ResourceLoader resourceLoader;
@Bean
@ConditionalOnBean(View.class)
@ConditionalOnMissingBean(InternalResourceViewResolver.class)
public InternalResourceViewResolver defaultViewResolver() {
InternalResourceViewResolver resolver = new InternalResourceViewResolver();
resolver.setPrefix(this.prefix);
resolver.setSuffix(this.suffix);
return resolver;
}
......
......@@ -18,24 +18,14 @@ package org.springframework.boot.sample.jsp;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.view.InternalResourceViewResolver;
@Configuration
@EnableAutoConfiguration
@ComponentScan
public class SampleWebJspApplication {
@Bean
public InternalResourceViewResolver defaultViewResolver() {
InternalResourceViewResolver resolver = new InternalResourceViewResolver();
resolver.setPrefix("/WEB-INF/jsp/");
resolver.setSuffix(".jsp");
return resolver;
}
public static void main(String[] args) throws Exception {
SpringApplication.run(SampleWebJspApplication.class, args);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment