Reputation: 319
I want to configure Spring to redirect all the requests to a specific Controller irrespective of the URL (length and parameters). How should I give the URL pattern / regular expression in the RequestMapping annotation. I tried using the below code, but it is not working. Any help in this regard is deeply appreciated.
@Controller
@RequestMapping("/*")
public class ServiceController {
@RequestMapping( method = RequestMethod.GET, value = "*" )
public void getProjectList(HttpServletRequest httpServletRequest,Model model){
}
}
Upvotes: 1
Views: 2469
Reputation: 48807
You need @RequestMapping(method = RequestMethod.GET, value = "/**")
.
In addition to URI templates, the
@RequestMapping
annotation also supports Ant-style path patterns (for example,/myPath/*.do
).
From http://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/util/AntPathMatcher.html:
The mapping matches URLs using the following rules:
?
matches one character*
matches zero or more characters**
matches zero or more directories in a path
Upvotes: 7
Reputation: 36
Have you tried with a regular expression?
Something like:
@RequestMapping("/{value:.}")
Upvotes: 0