This is my @RequestMapping
annotation:
@RequestMapping({"/loginBadCredentials", "/loginUserDisabled", "/loginUserNumberExceeded"})
public String errorLogin(...){
...
}
Inside the method errorLogin , is there a way to know which of the three url was "called"?
Simplest method is to inject HttpServletRequest and get the uri:
you can inject the HttpServletRequest into the method-parameters and then get the called uri.
Add
HttpServletRequest
as your parameters and use it to find the current request path.Update: Spring also provides
RequestContextHolder
:In my opinion, first approach is better and a little more testable.