I am trying to customize /error by implementing Error controller in a class annonated with RestController.
The Spring Boot app includes autoconfiguration Library and does not explicitly set or use MVC.
@RequestMapping("/error")
public String handler(){
return "Error Occurred";
}
The above code works fine when the error status is 401 and 404.
@RequestMapping("/error")
public void handler(HttpServletResponse response)
{
response.sendRedirect("http://<url>/home");
return;// edit: Even adding this statement is just setting location but not redirecting.
}
This is setting location in response with redirect url but not redirecting.
Requirement is to map the /error to external UI page.
Now, when I use, redirectview or responsentity, then, the logic in handler only works when /error is invoked manually and 404 is not invoking /error. It just says This page is not found. Can someone tell me is this because of autoconfiguration Library or am I missing anything?