Intercept error 404 with Spring

1

I need your help ... I have been sent to capture the error 404 on a page that is in use. The project is from Spring, but it's not mine and I've never touched it, so I do not know exactly how everything works. It has a driver to handle the errors, but it does not capture the 404. I have tried several functions but I can not capture it with any. The idea is that by detecting this error I will send you a personalized view of said web. Can someone help me with this?

I leave a bit of code of the error handler that you have, so you can see how it captures them.

@RequestMapping(value = "/error/json")
@ResponseBody
public ResponseEntity<String> handleExceptionJson(HttpServletRequest request) {
     return new ResponseEntity<>(HttpStatus.NOT_FOUND);
}

/**
 * Trata los errores no controlados de peticiones que esperaban respuestas
 * xml.
 * 
 * @param request
 *            objeto {@link HttpServletRequest} de la peticion que contiene
 *            un atributo "exception" con la excepcion causante del error.
 * @return objeto de respuesta con el mensaje de error.
 */
@RequestMapping(value = "/error/xml")
@ResponseBody
public Object handleExceptionXml(HttpServletRequest request) {
    // TODO: realizar el tratamiento deseado (normalmente devolver un xml de
    // error generico)
    return null;
} 

I hope you can help me.

Greetings!

    
asked by MMS 23.04.2018 в 12:55
source

0 answers