In my controller I have two methods which handle requests from user.
@RequestMapping(method = RequestMethod.GET)
@PreAuthorize("hasRole('ROLE_INTERNAL_USER')")
public String homeInt() {
return "redirect:/internal";
}
@RequestMapping(method = RequestMethod.GET)
@PreAuthorize("hasRole('ROLE_EXTERNAL_USER')")
public String homeExt() {
return "redirect:/external";
}
Exception:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping#0': Invocation of init method failed; nested exception is java.lang.IllegalStateException: Ambiguous mapping found. Cannot map 'loginController' bean method
public java.lang.String de.mark.project.web.controller.LoginController.homeInt()
to {[/],methods=[GET],params=[],headers=[],consumes=[],produces=[],custom=[]}: There is already 'loginController' bean method
public java.lang.String de.mark.project.web.controller.LoginController.homeExt() mapped.
But problem is that both methods couldn't mapped to one request method or to one URI. Is there any solution to map request in my kind of logic?