parent
c661a74c75
commit
923f286ae2
|
@ -28,6 +28,7 @@ import org.apache.commons.logging.LogFactory;
|
||||||
import org.springframework.beans.factory.BeanFactory;
|
import org.springframework.beans.factory.BeanFactory;
|
||||||
import org.springframework.beans.factory.ListableBeanFactory;
|
import org.springframework.beans.factory.ListableBeanFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
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.AutoConfigureAfter;
|
||||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
||||||
|
@ -110,6 +111,12 @@ public class WebMvcAutoConfiguration {
|
||||||
|
|
||||||
private static Log logger = LogFactory.getLog(WebMvcConfigurerAdapter.class);
|
private static Log logger = LogFactory.getLog(WebMvcConfigurerAdapter.class);
|
||||||
|
|
||||||
|
@Value("${spring.view.prefix:}")
|
||||||
|
private String prefix = "";
|
||||||
|
|
||||||
|
@Value("${spring.view.suffix:}")
|
||||||
|
private String suffix = "";
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ListableBeanFactory beanFactory;
|
private ListableBeanFactory beanFactory;
|
||||||
|
|
||||||
|
@ -117,10 +124,11 @@ public class WebMvcAutoConfiguration {
|
||||||
private ResourceLoader resourceLoader;
|
private ResourceLoader resourceLoader;
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
@ConditionalOnBean(View.class)
|
|
||||||
@ConditionalOnMissingBean(InternalResourceViewResolver.class)
|
@ConditionalOnMissingBean(InternalResourceViewResolver.class)
|
||||||
public InternalResourceViewResolver defaultViewResolver() {
|
public InternalResourceViewResolver defaultViewResolver() {
|
||||||
InternalResourceViewResolver resolver = new InternalResourceViewResolver();
|
InternalResourceViewResolver resolver = new InternalResourceViewResolver();
|
||||||
|
resolver.setPrefix(this.prefix);
|
||||||
|
resolver.setSuffix(this.suffix);
|
||||||
return resolver;
|
return resolver;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,24 +18,14 @@ package org.springframework.boot.sample.jsp;
|
||||||
|
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.context.annotation.ComponentScan;
|
import org.springframework.context.annotation.ComponentScan;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.web.servlet.view.InternalResourceViewResolver;
|
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
@EnableAutoConfiguration
|
@EnableAutoConfiguration
|
||||||
@ComponentScan
|
@ComponentScan
|
||||||
public class SampleWebJspApplication {
|
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 {
|
public static void main(String[] args) throws Exception {
|
||||||
SpringApplication.run(SampleWebJspApplication.class, args);
|
SpringApplication.run(SampleWebJspApplication.class, args);
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
spring.view.prefix: /WEB-INF/jsp/
|
||||||
|
spring.view.suffix: .jsp
|
Loading…
Reference in New Issue