您的位置:首页 > 其它

403、404、500在项目中的配置

2011-05-10 13:03 78 查看
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>
注意:红字部分是必须的!
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: