Package org.springframework.web.servlet.mvc.method.annotation

Examples of org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping


   * Return a {@link RequestMappingHandlerMapping} ordered at 0 for mapping
   * requests to annotated controllers.
   */
  @Bean
  public RequestMappingHandlerMapping requestMappingHandlerMapping() {
    RequestMappingHandlerMapping handlerMapping = new RequestMappingHandlerMapping();
    handlerMapping.setOrder(0);
    handlerMapping.setInterceptors(getInterceptors());
    return handlerMapping;
  }
View Full Code Here


   * Return a {@link RequestMappingHandlerMapping} ordered at 0 for mapping
   * requests to annotated controllers.
   */
  @Bean
  public RequestMappingHandlerMapping requestMappingHandlerMapping() {
    RequestMappingHandlerMapping handlerMapping = new RequestMappingHandlerMapping();
    handlerMapping.setOrder(0);
    handlerMapping.setRemoveSemicolonContent(false);
    handlerMapping.setInterceptors(getInterceptors());
    handlerMapping.setContentNegotiationManager(mvcContentNegotiationManager());
    return handlerMapping;
  }
View Full Code Here

  private void registerMvcSingletons(MockWebApplicationContext cxt) {

    StandaloneConfiguration configuration = new StandaloneConfiguration();

    RequestMappingHandlerMapping handlerMapping = configuration.requestMappingHandlerMapping();
    handlerMapping.setServletContext(cxt.getServletContext());
    handlerMapping.setApplicationContext(cxt);
    cxt.addBean("requestMappingHandlerMapping", handlerMapping);

    RequestMappingHandlerAdapter handlerAdapter = configuration.requestMappingHandlerAdapter();
    handlerAdapter.setServletContext(cxt.getServletContext());
    handlerAdapter.setApplicationContext(cxt);
View Full Code Here

        addHandler(controllerBeanName);
    }


    private void addHandler(String controllerBeanName) {
        RequestMappingHandlerMapping requestMappingHandlerMapping = requestMappingHandlerMapping();

        //remove old
        Class<?> handlerType = ctx.getType(controllerBeanName);
        final Class<?> userType = ClassUtils.getUserClass(handlerType);

        Map handlerMethods = (Map) ReflectionUtils.getField(handlerMethodsField, requestMappingHandlerMapping);
        MultiValueMap urlMapping = (MultiValueMap) ReflectionUtils.getField(urlMapField, requestMappingHandlerMapping);

        final RequestMappingHandlerMapping innerRequestMappingHandlerMapping = requestMappingHandlerMapping;
        Set<Method> methods = HandlerMethodSelector.selectMethods(userType, new ReflectionUtils.MethodFilter() {
            @Override
            public boolean matches(Method method) {
                return ReflectionUtils.invokeMethod(
                        getMappingForMethodMethod,
View Full Code Here

    private void removeOldControllerMapping(String controllerBeanName) {

        if (!beanFactory.containsBean(controllerBeanName)) {
            return;
        }
        RequestMappingHandlerMapping requestMappingHandlerMapping = requestMappingHandlerMapping();


        //remove old
        Class<?> handlerType = ctx.getType(controllerBeanName);
        final Class<?> userType = ClassUtils.getUserClass(handlerType);

        Map handlerMethods = (Map) ReflectionUtils.getField(handlerMethodsField, requestMappingHandlerMapping);
        MultiValueMap urlMapping = (MultiValueMap) ReflectionUtils.getField(urlMapField, requestMappingHandlerMapping);

        final RequestMappingHandlerMapping innerRequestMappingHandlerMapping = requestMappingHandlerMapping;
        Set<Method> methods = HandlerMethodSelector.selectMethods(userType, new ReflectionUtils.MethodFilter() {
            @Override
            public boolean matches(Method method) {
                return ReflectionUtils.invokeMethod(
                        getMappingForMethodMethod,
View Full Code Here

    private void addControllerMapping(String controllerBeanName) {

        removeOldControllerMapping(controllerBeanName);

        RequestMappingHandlerMapping requestMappingHandlerMapping = requestMappingHandlerMapping();
        //spring 3.1 开始
        ReflectionUtils.invokeMethod(detectHandlerMethodsMethod, requestMappingHandlerMapping, controllerBeanName);
    }
View Full Code Here

        assertThat(myList1, hasItem(isA(BeanImpl1.class)));

        assertEquals(1, myList2.size());
        assertThat(myList2, hasItem(isA(BeanImpl2.class)));

        RequestMappingHandlerMapping r;
    }
View Full Code Here

  }
 
  @Bean
  @Override
  public RequestMappingHandlerMapping requestMappingHandlerMapping() {
    RequestMappingHandlerMapping handlerMapping = super.requestMappingHandlerMapping();
    handlerMapping.setUseSuffixPatternMatch(false);
    return handlerMapping;
 
View Full Code Here

public class WebConfig extends WebMvcConfigurationSupport {

  @Override
  @Bean
  public RequestMappingHandlerMapping requestMappingHandlerMapping() {
    RequestMappingHandlerMapping mapping = super.requestMappingHandlerMapping();
    mapping.setAlwaysUseFullPath(true);
    return mapping;
  }
View Full Code Here

@Component
public class HandlerMappingConfigurer implements BeanPostProcessor, PriorityOrdered {

    public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
        if (bean instanceof RequestMappingHandlerMapping) {
            RequestMappingHandlerMapping requestMappingHandlerMapping = (RequestMappingHandlerMapping) bean;

            // URL decode after request mapping, not before.
            requestMappingHandlerMapping.setUrlDecode(false);

            // Workaround to make the previous fix work. See https://jira.springsource.org/browse/SPR-11101.
            requestMappingHandlerMapping.setAlwaysUseFullPath(true);

        }

        return bean;
    }
View Full Code Here

TOP

Related Classes of org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.