Search in sources :

Example 21 with RequestMappingHandlerMapping

use of org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping in project spring-framework by spring-projects.

the class StandaloneMockMvcBuilderTests method suffixPatternMatch.

// SPR-13637
@Test
public void suffixPatternMatch() throws Exception {
    TestStandaloneMockMvcBuilder builder = new TestStandaloneMockMvcBuilder(new PersonController());
    builder.setUseSuffixPatternMatch(false);
    builder.build();
    RequestMappingHandlerMapping hm = builder.wac.getBean(RequestMappingHandlerMapping.class);
    MockHttpServletRequest request = new MockHttpServletRequest("GET", "/persons");
    HandlerExecutionChain chain = hm.getHandler(request);
    assertNotNull(chain);
    assertEquals("persons", ((HandlerMethod) chain.getHandler()).getMethod().getName());
    request = new MockHttpServletRequest("GET", "/persons.xml");
    chain = hm.getHandler(request);
    assertNull(chain);
}
Also used : HandlerExecutionChain(org.springframework.web.servlet.HandlerExecutionChain) MockHttpServletRequest(org.springframework.mock.web.test.MockHttpServletRequest) RequestMappingHandlerMapping(org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping) HandlerMethod(org.springframework.web.method.HandlerMethod) Test(org.junit.Test)

Example 22 with RequestMappingHandlerMapping

use of org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping in project Activiti by Activiti.

the class DispatcherServletConfiguration method requestMappingHandlerMapping.

@Bean
public RequestMappingHandlerMapping requestMappingHandlerMapping() {
    log.debug("Creating requestMappingHandlerMapping");
    RequestMappingHandlerMapping requestMappingHandlerMapping = new RequestMappingHandlerMapping();
    requestMappingHandlerMapping.setUseSuffixPatternMatch(false);
    Object[] interceptors = { localeChangeInterceptor() };
    requestMappingHandlerMapping.setInterceptors(interceptors);
    return requestMappingHandlerMapping;
}
Also used : RequestMappingHandlerMapping(org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping) Bean(org.springframework.context.annotation.Bean)

Example 23 with RequestMappingHandlerMapping

use of org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping in project Activiti by Activiti.

the class DispatcherServletConfiguration method requestMappingHandlerMapping.

@Bean
public RequestMappingHandlerMapping requestMappingHandlerMapping() {
    log.debug("Creating requestMappingHandlerMapping");
    RequestMappingHandlerMapping requestMappingHandlerMapping = new RequestMappingHandlerMapping();
    requestMappingHandlerMapping.setUseSuffixPatternMatch(false);
    Object[] interceptors = { localeChangeInterceptor() };
    requestMappingHandlerMapping.setInterceptors(interceptors);
    return requestMappingHandlerMapping;
}
Also used : RequestMappingHandlerMapping(org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping) Bean(org.springframework.context.annotation.Bean)

Example 24 with RequestMappingHandlerMapping

use of org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping in project Activiti by Activiti.

the class DispatcherServletConfiguration method requestMappingHandlerMapping.

@Bean
public RequestMappingHandlerMapping requestMappingHandlerMapping() {
    log.debug("Creating requestMappingHandlerMapping");
    RequestMappingHandlerMapping requestMappingHandlerMapping = new RequestMappingHandlerMapping();
    requestMappingHandlerMapping.setUseSuffixPatternMatch(false);
    Object[] interceptors = { localeChangeInterceptor() };
    requestMappingHandlerMapping.setInterceptors(interceptors);
    return requestMappingHandlerMapping;
}
Also used : RequestMappingHandlerMapping(org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping) Bean(org.springframework.context.annotation.Bean)

Example 25 with RequestMappingHandlerMapping

use of org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping in project chassis by Kixeye.

the class SpringMvcConfiguration method requestMappingHandlerMapping.

/**
     * Return a {@link RequestMappingHandlerMapping} ordered at 0 for mapping
     * requests to annotated controllers.
     */
@Bean
@Override
public RequestMappingHandlerMapping requestMappingHandlerMapping() {
    PathMatchConfigurer configurer = new PathMatchConfigurer();
    configurePathMatch(configurer);
    RequestMappingHandlerMapping handlerMapping = new RequestMappingHandlerMapping();
    handlerMapping.setOrder(0);
    handlerMapping.setDetectHandlerMethodsInAncestorContexts(true);
    handlerMapping.setInterceptors(getInterceptors());
    handlerMapping.setContentNegotiationManager(mvcContentNegotiationManager());
    if (configurer.isUseSuffixPatternMatch() != null) {
        handlerMapping.setUseSuffixPatternMatch(configurer.isUseSuffixPatternMatch());
    }
    if (configurer.isUseRegisteredSuffixPatternMatch() != null) {
        handlerMapping.setUseRegisteredSuffixPatternMatch(configurer.isUseRegisteredSuffixPatternMatch());
    }
    if (configurer.isUseTrailingSlashMatch() != null) {
        handlerMapping.setUseTrailingSlashMatch(configurer.isUseTrailingSlashMatch());
    }
    if (configurer.getPathMatcher() != null) {
        handlerMapping.setPathMatcher(configurer.getPathMatcher());
    }
    if (configurer.getUrlPathHelper() != null) {
        handlerMapping.setUrlPathHelper(configurer.getUrlPathHelper());
    }
    return handlerMapping;
}
Also used : RequestMappingHandlerMapping(org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping) PathMatchConfigurer(org.springframework.web.servlet.config.annotation.PathMatchConfigurer) Bean(org.springframework.context.annotation.Bean)

Aggregations

RequestMappingHandlerMapping (org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping)25 Test (org.junit.Test)17 MockHttpServletRequest (org.springframework.mock.web.test.MockHttpServletRequest)13 HandlerExecutionChain (org.springframework.web.servlet.HandlerExecutionChain)11 Bean (org.springframework.context.annotation.Bean)6 ConversionServiceExposingInterceptor (org.springframework.web.servlet.handler.ConversionServiceExposingInterceptor)6 MockHttpServletResponse (org.springframework.mock.web.test.MockHttpServletResponse)5 ContentNegotiationManager (org.springframework.web.accept.ContentNegotiationManager)4 NativeWebRequest (org.springframework.web.context.request.NativeWebRequest)4 ServletWebRequest (org.springframework.web.context.request.ServletWebRequest)4 SimpleUrlHandlerMapping (org.springframework.web.servlet.handler.SimpleUrlHandlerMapping)4 LocaleChangeInterceptor (org.springframework.web.servlet.i18n.LocaleChangeInterceptor)4 RequestMappingHandlerAdapter (org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter)4 ThemeChangeInterceptor (org.springframework.web.servlet.theme.ThemeChangeInterceptor)4 DirectFieldAccessor (org.springframework.beans.DirectFieldAccessor)3 PathMatcher (org.springframework.util.PathMatcher)3 AnnotationConfigWebApplicationContext (org.springframework.web.context.support.AnnotationConfigWebApplicationContext)3 HandlerMethod (org.springframework.web.method.HandlerMethod)3 HandlerInterceptor (org.springframework.web.servlet.HandlerInterceptor)3 UrlPathHelper (org.springframework.web.util.UrlPathHelper)3