您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

使用Spring DispatcherServlet的自定义404

使用Spring DispatcherServlet的自定义404

一种选择是通过调度程序servlet映射所有错误页面

创建一个新的HTTP错误控制器:

@Controller
public class HTTPErrorController {

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

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

}

映射web.xml中的错误页面

<error-page>
    <error-code>404</error-code>
    <location>/errors/404.html</location>
Jave 2022/1/1 18:20:57 有353人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶