對404錯誤和500錯誤處理:
在WebContent檔案下建立404.jsp 和 500.jsp 顯示錯誤時彈出的資訊
<%@ page language="java" contentType="text/html; charset=utf-8"
pageEncoding="utf-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>404</title>
</head>
<body>
找不到請求路徑!
</body>
</html>
<%@ page language="java" contentType="text/html; charset=utf-8"
pageEncoding="utf-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>500</title>
</head>
<body>
内部錯誤!
</body>
</html>
在web.xml裡配置路徑:
<error-page>
<error-code>500</error-code>
<location>/500.jsp</location>
</error-page>
<error-page>
<error-code>404</error-code>
<location>/404.jsp</location>
</error-page>
重新啟動路徑即可!
轉載于:https://www.cnblogs.com/jj81/p/10163659.html