Encoded slash (/) with Spring RequestMapping path param gives HTTP 400

前端 未结 9 808
陌清茗
陌清茗 2020-12-05 00:10

This is not a duplicate referenced question, because it is Spring specific. Whoever added that (3 years after the fact!) didn\'t bother to read the question or comment

9条回答
  •  北荒
    北荒 (楼主)
    2020-12-05 00:43

    I have found this solution which is working for me;

    System.setProperty("org.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH", "true");
    

    just before springApplication.run(args);

    and add below code in Application class

     @Override
        public void configurePathMatch(PathMatchConfigurer configurer) {
            UrlPathHelper urlPathHelper = new UrlPathHelper();
            urlPathHelper.setUrlDecode(false);
            configurer.setUrlPathHelper(urlPathHelper);
        }
    

提交回复
热议问题