use of org.springframework.web.servlet.view.InternalResourceViewResolver in project spring-framework by spring-projects.
the class WebMvcConfigurationSupport method mvcViewResolver.
/**
* Register a {@link ViewResolverComposite} that contains a chain of view resolvers
* to use for view resolution.
* By default this resolver is ordered at 0 unless content negotiation view
* resolution is used in which case the order is raised to
* {@link org.springframework.core.Ordered#HIGHEST_PRECEDENCE
* Ordered.HIGHEST_PRECEDENCE}.
* <p>If no other resolvers are configured,
* {@link ViewResolverComposite#resolveViewName(String, Locale)} returns null in order
* to allow other potential {@link ViewResolver} beans to resolve views.
* @since 4.1
*/
@Bean
public ViewResolver mvcViewResolver() {
ViewResolverRegistry registry = new ViewResolverRegistry();
registry.setContentNegotiationManager(mvcContentNegotiationManager());
registry.setApplicationContext(this.applicationContext);
configureViewResolvers(registry);
if (registry.getViewResolvers().isEmpty()) {
String[] names = BeanFactoryUtils.beanNamesForTypeIncludingAncestors(this.applicationContext, ViewResolver.class, true, false);
if (names.length == 1) {
registry.getViewResolvers().add(new InternalResourceViewResolver());
}
}
ViewResolverComposite composite = new ViewResolverComposite();
composite.setOrder(registry.getOrder());
composite.setViewResolvers(registry.getViewResolvers());
composite.setApplicationContext(this.applicationContext);
composite.setServletContext(this.servletContext);
return composite;
}
use of org.springframework.web.servlet.view.InternalResourceViewResolver in project spring-framework by spring-projects.
the class ViewResolverRegistryTests method customViewResolver.
@Test
public void customViewResolver() {
InternalResourceViewResolver viewResolver = new InternalResourceViewResolver("/", ".jsp");
this.registry.viewResolver(viewResolver);
assertSame(viewResolver, this.registry.getViewResolvers().get(0));
}
use of org.springframework.web.servlet.view.InternalResourceViewResolver in project spring-framework by spring-projects.
the class ViewResolverRegistryTests method jsp.
@Test
public void jsp() {
this.registry.jsp("/", ".jsp");
InternalResourceViewResolver resolver = checkAndGetResolver(InternalResourceViewResolver.class);
checkPropertyValues(resolver, "prefix", "/", "suffix", ".jsp");
}
use of org.springframework.web.servlet.view.InternalResourceViewResolver in project spring-framework by spring-projects.
the class ViewResolverRegistryTests method jspDefaultValues.
@Test
public void jspDefaultValues() {
this.registry.jsp();
InternalResourceViewResolver resolver = checkAndGetResolver(InternalResourceViewResolver.class);
checkPropertyValues(resolver, "prefix", "/WEB-INF/", "suffix", ".jsp");
}
use of org.springframework.web.servlet.view.InternalResourceViewResolver in project spring-security-oauth by spring-projects.
the class WebMvcConfig method viewResolver.
@Bean
public ViewResolver viewResolver() {
InternalResourceViewResolver viewResolver = new InternalResourceViewResolver();
viewResolver.setPrefix("/WEB-INF/jsp/");
viewResolver.setSuffix(".jsp");
return viewResolver;
}
Aggregations