How I create an error handler (404, 500...) in Spring Boot/MVC
<p>For some hours I'm trying to create a <em>custom</em> global error handler in Spring Boot/MVC. I've read a lot of articles and nothing.</p>

<p>That is my error class:</p>

<p>I tried create a class like that</p>

<pre><code>@Controller
public class ErrorPagesController {

    @RequestMapping("/404")
    @ResponseStatus(HttpStatus.NOT_FOUND)
    public String notFound() {
        return "/error/404";
    }

    @RequestMapping("/403")
    @ResponseStatus(HttpStatus.FORBIDDEN)
    public String forbidden() {
        return "/error/403";
    }

    @RequestMapping("/500")
    @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
    public String internalServerError() {
        return "/error/500";
    }

}
</code></pre>