Custom 404 using Spring DispatcherServlet

馋奶兔 提交于 2019-11-27 11:29:38

One option is to map all your error pages through your dispatcher servlet.

Create a new HTTP error controller:


@Controller
public class HTTPErrorController {

    @RequestMapping(value="/errors/404.html")
    public String handle404() {
        return "errorPageTemplate";
    }

    @RequestMapping(value="/errors/403.html")
    ...

}

Map the error pages in web.xml

<error-page>
    <error-code>404</error-code>
    <location>/errors/404.html</location>
</error-page>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!