How to match a Spring @RequestMapping having a @pathVariable containing "/"?
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());
...
}