How to match a Spring @RequestMapping having a @pathVariable containing “/”?

前端 未结 2 1630
心在旅途
心在旅途 2020-12-01 08:32

I am doing the following request from the client:

/search/hello%2Fthere/

where the search term \"hello/there\" has been URLencoded.

On t

2条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-01 09:16

        @Configuration
        public class AdditionalWebConfig extends WebMvcConfigurationSupport {
         .......
         ...........
         ...........
        @Override
        public void configureContentNegotiation(ContentNegotiationConfigurer 
        configurer) {
           configurer.favorPathExtension(false);
        }
        .......
        .......
      }
    

    and add regex like this in @PathVariable("user/{username:.+}")

提交回复
热议问题