use of org.springframework.web.servlet.handler.AbstractHandlerMapping in project spring-framework by spring-projects.
the class WebMvcConfigurationSupportTests method emptyResourceHandlerMapping.
@Test
public void emptyResourceHandlerMapping() {
ApplicationContext context = initContext(WebConfig.class);
AbstractHandlerMapping handlerMapping = context.getBean("resourceHandlerMapping", AbstractHandlerMapping.class);
assertNotNull(handlerMapping);
assertEquals(Integer.MAX_VALUE, handlerMapping.getOrder());
assertTrue(handlerMapping.getClass().getName().endsWith("EmptyHandlerMapping"));
}
use of org.springframework.web.servlet.handler.AbstractHandlerMapping in project spring-framework by spring-projects.
the class WebMvcConfigurationSupport method viewControllerHandlerMapping.
/**
* Return a handler mapping ordered at 1 to map URL paths directly to
* view names. To configure view controllers, override
* {@link #addViewControllers}.
*/
@Bean
@Nullable
public HandlerMapping viewControllerHandlerMapping(@Qualifier("mvcConversionService") FormattingConversionService conversionService, @Qualifier("mvcResourceUrlProvider") ResourceUrlProvider resourceUrlProvider) {
ViewControllerRegistry registry = new ViewControllerRegistry(this.applicationContext);
addViewControllers(registry);
AbstractHandlerMapping handlerMapping = registry.buildHandlerMapping();
if (handlerMapping == null) {
return null;
}
PathMatchConfigurer pathConfig = getPathMatchConfigurer();
if (pathConfig.getPatternParser() != null) {
handlerMapping.setPatternParser(pathConfig.getPatternParser());
} else {
handlerMapping.setUrlPathHelper(pathConfig.getUrlPathHelperOrDefault());
handlerMapping.setPathMatcher(pathConfig.getPathMatcherOrDefault());
}
handlerMapping.setInterceptors(getInterceptors(conversionService, resourceUrlProvider));
handlerMapping.setCorsConfigurations(getCorsConfigurations());
return handlerMapping;
}
use of org.springframework.web.servlet.handler.AbstractHandlerMapping in project spring-framework by spring-projects.
the class DelegatingWebMvcConfigurationIntegrationTests method viewControllerHandlerMappingWithPrimaryUsesQualifiedPathMatcher.
@Test
void viewControllerHandlerMappingWithPrimaryUsesQualifiedPathMatcher() {
load(registerPrimaryBean("testPathMatcher", PathMatcher.class).andThen(context -> context.registerBean(ViewControllerConfiguration.class)));
AbstractHandlerMapping handlerMapping = this.context.getBean("viewControllerHandlerMapping", AbstractHandlerMapping.class);
assertThat(handlerMapping.getPathMatcher()).isSameAs(this.context.getBean("mvcPathMatcher"));
assertThat(this.context.getBeansOfType(PathMatcher.class)).containsOnlyKeys("mvcPathMatcher", "testPathMatcher");
}
use of org.springframework.web.servlet.handler.AbstractHandlerMapping in project spring-framework by spring-projects.
the class DelegatingWebMvcConfigurationIntegrationTests method resourceHandlerMappingWithPrimaryUsesQualifiedUrlPathHelper.
@Test
void resourceHandlerMappingWithPrimaryUsesQualifiedUrlPathHelper() {
load(registerPrimaryBean("testUrlPathHelper", UrlPathHelper.class).andThen(context -> context.registerBean(ResourceHandlerConfiguration.class)));
AbstractHandlerMapping handlerMapping = this.context.getBean("resourceHandlerMapping", AbstractHandlerMapping.class);
assertThat(handlerMapping.getUrlPathHelper()).isSameAs(this.context.getBean("mvcUrlPathHelper"));
assertThat(this.context.getBeansOfType(UrlPathHelper.class)).containsOnlyKeys("mvcUrlPathHelper", "testUrlPathHelper");
}
use of org.springframework.web.servlet.handler.AbstractHandlerMapping in project spring-framework by spring-projects.
the class DelegatingWebMvcConfigurationIntegrationTests method viewControllerHandlerMappingWithPrimaryUsesQualifiedUrlPathHelper.
@Test
void viewControllerHandlerMappingWithPrimaryUsesQualifiedUrlPathHelper() {
load(registerPrimaryBean("testUrlPathHelper", UrlPathHelper.class).andThen(context -> context.registerBean(ViewControllerConfiguration.class)));
AbstractHandlerMapping handlerMapping = this.context.getBean("viewControllerHandlerMapping", AbstractHandlerMapping.class);
assertThat(handlerMapping.getUrlPathHelper()).isSameAs(this.context.getBean("mvcUrlPathHelper"));
assertThat(this.context.getBeansOfType(UrlPathHelper.class)).containsOnlyKeys("mvcUrlPathHelper", "testUrlPathHelper");
}
Aggregations