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

后端 未结 17 1563
被撕碎了的回忆
被撕碎了的回忆 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:30

    Finally I found solution in Spring Docs:

    To completely disable the use of file extensions, you must set both of the following:

     useSuffixPatternMatching(false), see PathMatchConfigurer
    
     favorPathExtension(false), see ContentNegotiationConfigurer
    

    Adding this to my WebMvcConfigurerAdapter implementation solved the problem:

    @Override
    public void configureContentNegotiation(ContentNegotiationConfigurer configurer) {
        configurer.favorPathExtension(false);
    }
    
    @Override
    public void configurePathMatch(PathMatchConfigurer matcher) {
        matcher.setUseSuffixPatternMatch(false);
    }
    

提交回复
热议问题