Spring MVC @PathVariable with dot (.) is getting truncated

后端 未结 17 1681
被撕碎了的回忆
被撕碎了的回忆 2020-11-22 06:00

This is continuation of question Spring MVC @PathVariable getting truncated

Spring forum states that it has fixed(3.2 version) as part of ContentNegotiationManager.

17条回答
  •  佛祖请我去吃肉
    2020-11-22 06:49

    If you are using Spring 3.2.x and , create this little BeanPostProcessor:

    package spring;
    
    public final class DoNotTruncateMyUrls implements BeanPostProcessor {
        @Override
        public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
            if (bean instanceof RequestMappingHandlerMapping) {
                ((RequestMappingHandlerMapping)bean).setUseSuffixPatternMatch(false);
            }
            return bean;
        }
        @Override
        public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
            return bean;
        }
    }
    

    Then put this in your MVC config xml:

    
    

提交回复
热议问题