Jsp异常

web.xml

 

 <error-page>
  	<exception-type>com.chinacreator.security. SessionTimeoutExcetpion </exception-type>
  	<location>/sysmanager/logoutredirect.jsp</location>
  </error-page>

<error-page>
		<error-code>500</error-code>
		<location>/error.jsp</location>
	</error-page>
	<error-page>
		<error-code>400</error-code>
		<location>/index.jsp</location>
	</error-page>
	<error-page>
		<error-code>403</error-code>
		<location>/403.jsp</location>
	</error-page>
	<error-page>
		<error-code>404</error-code>
		<location>/404.jsp</location>
	</error-page>

 

jquery load

$("#divId>").load(
				href,
				{},
				function(responseText , textStatus){
					if (textStatus == "error"){
						$("#divId").html(responseText);
					}
				}
			);

  因为load方法,未做textstatus为error的情况进行处理,jquery的源码

jQuery.fn.extend({
	load: function( url, params, callback ) {
		。。。

		// Default to a GET request
		var type = "GET";

		// If the second parameter was provided
		if ( params ) {
			// If it's a function
			if ( jQuery.isFunction( params ) ) {
				// We assume that it's the callback
				callback = params;
				params = null;

			// Otherwise, build a param string
			} else if ( typeof params === "object" ) {
				params = jQuery.param( params, jQuery.ajaxSettings.traditional );
				type = "POST";
			}
		}

		var self = this;

		// Request the remote document
		jQuery.ajax({
			url: url,
			type: type,
			dataType: "html",
			data: params,
			complete: function( res, status ) {
				// If successful, inject the HTML into all the matched elements
				if ( status === "success" || status === "notmodified" ) {
					// See if a selector was specified
					self.html( selector ?
						// Create a dummy div to hold the results
						jQuery("<div />")
							// inject the contents of the document in, removing the scripts
							// to avoid any 'Permission Denied' errors in IE
							.append(res.responseText.replace(rscript, ""))

							// Locate the specified elements
							.find(selector) :

						// If not, just inject the full result
						res.responseText );
				}

				if ( callback ) {
					self.each( callback, [res.responseText, status, res] );
				}
			}
		});

		return this;
	},
 

 

 

error.jsp

<%@ page language="java" isErrorPage="true" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>
<%@ page pageEncoding="UTF-8"%>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
    <title><fmt:message key="errorPage.title"/></title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> 
    <link rel="stylesheet" type="text/css" media="all" href="<c:url value='/styles/${appConfig["csstheme"]}/theme.css'/>" />
</head>
<script language="javascript">

function showT(){
	var content = document.getElementById("exceptions");
	if(content.style.display == "none"){
		content.style.display = "";
	}else{
		content.style.display = "none";
	}
}
</script>
<body id="error">
<br>

 
                <%-- Error Messages --%>
                <logic:messagesPresent>
                    <logic:present name="error">
                    <div class="error">
                        <html:messages id="error">
                            <c:out value="${error}" escapeXml="false"/><br/>
                        </html:messages>
                    </div>
                    </logic:present>
                </logic:messagesPresent>
                <div class="error" Style="width:800px;"><img src="images/iconWarning.gif" />
                 后台处理异常,<a onClick="javascript:showT();" href="#">查看详细异常</a>
			    <div id='exceptions' style="display :none;OVERFLOW: auto;width:800px;height:460" >              
                 <% if (exception != null) { %>
                    <pre><% exception.printStackTrace(new java.io.PrintWriter(out)); %></pre>
                <% } else if ((Exception)request.getAttribute("javax.servlet.error.exception") != null) { %>
                    <pre><% ((Exception)request.getAttribute("javax.servlet.error.exception"))
                                           .printStackTrace(new java.io.PrintWriter(out)); %></pre>
                <% } else if (pageContext.findAttribute("org.apache.struts.action.EXCEPTION") != null) { %>
                    <bean:define id="exception2" name="org.apache.struts.action.EXCEPTION"
                     type="java.lang.Exception"/>
                    <c:if test="${exception2 != null}">
                        <pre><% exception2.printStackTrace(new java.io.PrintWriter(out));%></pre>
                    </c:if>
                    <%-- only show this if no error messages present --%>
                    <c:if test="${exception2 == null}">
                        <fmt:message key="errors.none"/>
                    </c:if>
                <% } %>
                
                
            
        </div>
    </div>
</body>
</html>
   

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值