I\'m looking for a clean way to return customized 404 errorpages in Spring 4 when a requested resource was not found. Queries to different domain types should result in diff
You can map the error codes in web.xml like the following
400
/400
404
/404
500
/500
Now you can create a controller to map the url's that are hit when any of these error is found.
@Controller
public class HTTPErrorHandler{
String path = "/error";
@RequestMapping(value="/404")
public String error404(){
// DO stuff here
return path+"/404";
}
}
For full example see my tutorial about this