1 403、404、500介绍
HTTP 403 - 禁止访问
HTTP 404 - 无法找到文件
HTTP 500 - 内部服务器错误
2 403、404、500在项目中配置
(1) web.xml
<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>
<error-page>
<error-code>403</error-code>
<location>/403.jsp</location>
</error-page>
(2) jsp页面
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<%@ page language="java" contentType="text/html; charset=UTF-8" isErrorPage="true" pageEncoding="UTF-8" %>
<% response.setStatus(HttpServletResponse.SC_OK); %>
<head>
<title>友情提示500</title>
</head>
<body>
<font style="font-size:18px; font-weight:bold; color:#333;">您访问的页面不存在!</font>
</body>
</html>
注意:红字部分是必须的!