<!-- Exception Resolver--> <bean id="exceptionResolver" class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver"> <property name="defaultErrorView"> <value>/exception/failure</value> </property> <property name="exceptionMappings"> <props> <prop key="java.sql.SQLException">/exception/showDBError</prop> <prop key="java.lang.RuntimeException">/exception/showError</prop> </props> </property> </bean> |
错误显示页面 <c:set value="${exception}" var="ee"/> <jsp:useBean id="ee" type="java.lang.Exception" /> <%=ee.getMessage()%><br> <%ee.printStackTrace( new java.io.PrintWriter(out));%> |
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core_rt"%> <%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%> <%@ page contentType="text/html;charset=GBK" language="java" pageEncoding="GBK"%> <%@ page import="java.util.Enumeration,java.util.Iterator"%> <script> function showErr(){ var isHidde = document.all.isHidde.value; //alert(isHidde); if( isHidde == "true" ){ document.all.errdiv.style.display=’block’; document.all.isHidde.value= ’false’; document.all.showbtn.value="隐藏错误信息"; }else{ document.all.errdiv.style.display=’none’; document.all.isHidde.value= ’true’; document.all.showbtn.value="显示错误信息"; } } </script> <html> <head> <title>this is failure</title> </head> <body onload="showErr()"> <c:set value="${exception}" var="ee"/> <jsp:useBean id="ee" type="java.lang.Exception" /> <%=ee.getMessage()%>ok,<br> <table id="errdiv" align="center" bgcolor="darkseagreen"> <tr><td> <font color=red> <%ee.printStackTrace( new java.io.PrintWriter(out));%> </font> </td></tr></table> <input type="hidden" id="isHidde" value="true"/> <input type="button" id="showbtn" onclick="showErr();"/> </body> </html> |
新闻热点
疑难解答