@Controller
public class Controller404 {
    @RequestMapping("/404")
    public String error404() {
        return "/404";
    }
}Чтоб отловить ошибки. 
@ControllerAdvice
public class MyExceptionHandler {
    @ResponseStatus(HttpStatus.FORBIDDEN)
    @ExceptionHandler(Exception.class)
    public String handler(Exception ex){
        return "/404";
    }