I am doing the following request from the client:
/search/hello%2Fthere/
where the search term \"hello/there\" has been URLencoded.
On t
There are no good ways to do it (without dealing with HttpServletResponse
). You can do something like this:
@RequestMapping("/search/**")
public Map searchWithSearchTerm(HttpServletRequest request) {
// Don't repeat a pattern
String pattern = (String)
request.getAttribute(HandlerMapping.BEST_MATCHING_PATTERN_ATTRIBUTE);
String searchTerm = new AntPathMatcher().extractPathWithinPattern(pattern,
request.getServletPath());
...
}
@Configuration
public class AdditionalWebConfig extends WebMvcConfigurationSupport {
.......
...........
...........
@Override
public void configureContentNegotiation(ContentNegotiationConfigurer
configurer) {
configurer.favorPathExtension(false);
}
.......
.......
}
and add regex like this in @PathVariable("user/{username:.+}")