在web.xml配置一下:
image.png如果需要拷贝代码复制下面的:
<error-page>
<error-code>404</error-code>
<location>/WEB-INF/jsp/404.jsp</location>
</error-page>
<error-page>
<exception-type>java.lang.Throwable</exception-type>
<location>/WEB-INF/jsp/500.jsp</location>
</error-page>
<error-page>
<error-code>500</error-code>
<location>/WEB-INF/jsp/500.jsp</location>
</error-page>
如果是jsp页面需要在页面加上isErrorPage="true"(html页面不用加),如果不加会跳到浏览器自身的404/500页面
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8" isErrorPage="true"%>
image.png
网友评论