java web application 配置403、404、500错误页面

来源:互联网 发布:北大元培学院知乎 编辑:程序博客网 时间:2024/06/16 04:48

两个要点:

1. 在web.xml中加入:

<error-page>    <error-code>403</error-code>    <location>/403.jsp</location></error-page><error-page>    <error-code>404</error-code>    <location>/404.jsp</location></error-page><error-page>    <error-code>500</error-code>    <location>/500.jsp</location></error-page>

2. 在错误页面中(403.jsp, 404.jsp, 500.jsp)需要加入:

<%@ page contentType="text/html;charset=UTF-8" isErrorPage="true"%><% response.setStatus(HttpServletResponse.SC_OK);%>



原创粉丝点击