1.web.xml加入以下配置

 <error-page>
    <error-code>404</error-code>
    <location>/WEB-INF/include/error.jsp</location>
    </error-page>
    <error-page>
    <error-code>500</error-code>
    <location>/WEB-INF/include/error.jsp</location>
    </error-page>
    <error-page>
    <error-code>java.lang.Exception</error-code>
    <location>/WEB-INF/include/error.jsp</location>
    </error-page>

2.新建error.jsp

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" isErrorPage="true" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Error</title>
</head>
<body>
<%
  response.setStatus(200);
%>
很抱歉,您请求的页面不存在......
</body>
</html>

3.测试

http://ip:端口号/项目名/index

相关文章:

  • 2021-11-28
  • 2022-12-23
  • 2021-09-21
  • 2022-01-22
  • 2021-11-18
  • 2022-12-23
  • 2022-01-06
猜你喜欢
  • 2022-12-23
  • 2021-04-28
  • 2021-12-01
  • 2021-08-09
  • 2022-12-23
  • 2021-07-04
  • 2022-01-25
相关资源
相似解决方案