首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > Web前端 >

烂笔尖-相关配置

2012-10-08 
烂笔头--相关配置1,页面的web.xml配置,指定错误页面 error-pageerror-code404/error-codelocation

烂笔头--相关配置
1,页面的web.xml配置,指定错误页面

<error-page>
  <error-code>404</error-code>
  <location>/building.jsp</location>
</error-page>

<error-page>
  <error-code>500</error-code>
  <location>/error.jsp</location>
</error-page>



需注意:<location>/error.jsp</location> 必须以“/”开始



错误页面:

building.jsp

<%@ page language="java" contentType="text/html; charset=GBK"
isErrorPage="true" pageEncoding="GBK"%>
<%response.setStatus(HttpServletResponse.SC_OK);%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<HEAD>
<title>抱歉!您要查看的网页当前已过期,或已被更名或删除!</title>
<STYLE type=text/css>
INPUT {
FONT-SIZE: 12px
}

TD {
FONT-SIZE: 12px
}

.p2 {
FONT-SIZE: 12px
}

.p6 {
FONT-SIZE: 12px;
COLOR: #1b6ad8
}

A {
COLOR: #1b6ad8;
TEXT-DECORATION: none
}

A:hover {
COLOR: red
}
</STYLE>

</HEAD>
<BODY oncontextmenu="return false" onselectstart="return false">
<P align=center></P>
<P align=center></P>
<TABLE cellSpacing=0 cellPadding=0 width=540 align=center border=0>
<TBODY>
  <TR>
   <TD vAlign=top height=270>
   <DIV align=center><BR>
   <IMG height=211 src="<%=request.getContextPath()%>/images/error/error.gif" width=329><BR>
   <BR>
   <TABLE cellSpacing=0 cellPadding=0 width="80%" border=0>
    <TBODY>
     <TR>
      <TD><FONT class=p2>&nbsp;&nbsp;&nbsp;
           <FONT color=#ff0000>
           <IMG height=13 src="<%=request.getContextPath()%>/images/error/emessage.gif" width=12>&nbsp;
                    无法访问本页的原因是:</FONT>
           </FONT></TD>
     </TR>
     <TR>
      <TD height=8></TD>
     <TR>
      <TD>
      <P><FONT color=#000000><BR>
      您所请求的页面不存在</FONT>!</P>
      </TD>
     </TR>
    </TBODY>
   </TABLE>
   </DIV>
   </TD>
  </TR>
  <TR>
   <TD height=5></TD>
  <TR>
   <TD align=middle>
   <CENTER>
   <TABLE cellSpacing=0 cellPadding=0 width=480 border=0>
    <TBODY>
     <TR>
      <TD width=6><IMG height=26 src="<%=request.getContextPath()%>/images/error/left.gif" width=7></TD>
      <TD background="<%=request.getContextPath()%>/images/error/bg.gif">
      <DIV align=center>
      <FONT class=p6>
          <A href="<%=basePath %>">返回首页</A> |
       <A href="#" onClick="history.go(-1);return false">返回出错页</A> |
       <A href="#" onClick="window.close();return false;">关闭本页</A>
         </FONT></DIV>
      </TD>
      <TD width=7><IMG src="<%=request.getContextPath()%>/images/error/right.gif"></TD>
     </TR>
    </TBODY>
   </TABLE>
   </CENTER>
   </TD>
  </TR>
</TBODY>
</TABLE>
<P align=center></P>
<P align=center></P>
</BODY>
</HTML>



error.jsp

<%@ page language="java" contentType="text/html; charset=GBK" isErrorPage="true" pageEncoding="GBK"%>
<%@ page import="java.io.*,java.util.*"%>
<%response.setStatus(HttpServletResponse.SC_OK);
      %>
<body>
程序发生了错误,有可能该页面正在调试或者是设计上的缺陷.<br/>
你可以选择<br/> <a href=<%=request.getContextPath()+"/forum/new.jsp" %>>反馈</a>
提醒我... 或者<br/><a href="javascript:history.go(-1)">返回上一页</a>
<hr width=80%>
<h2><font color=#DB1260>JSP Error Page</font></h2>
<p>An exception was thrown: <b> <%=exception.getClass()%>:<%=exception.getMessage()%></b></p>
<%
System.out.println("Header....");
Enumeration<String> e = request.getHeaderNames();
String key;
while(e.hasMoreElements()){
  key = e.nextElement();
  System.out.println(key+"="+request.getHeader(key));
}
System.out.println("Attribute....");
e = request.getAttributeNames();
while(e.hasMoreElements()){
  key = e.nextElement();
  System.out.println(key+"="+request.getAttribute(key));
}
System.out.println("Parameter....");
e = request.getParameterNames();
while(e.hasMoreElements()){
  key = e.nextElement();
  System.out.println(key+"="+request.getParameter(key));
}
%>
<%=request.getAttribute("javax.servlet.forward.request_uri") %><br>
<%=request.getAttribute("javax.servlet.forward.servlet_path") %>
<p>With the following stack trace:</p>
<pre>
<%exception.printStackTrace();
      ByteArrayOutputStream ostr = new ByteArrayOutputStream();
      exception.printStackTrace(new PrintStream(ostr));
      out.print(ostr);
    %>
</pre>
<hr width=80%>
</body>



2,Log4J打印ibatis的SQL语句:

log4j.logger.com.ibatis=debug
log4j.logger.com.ibatis.common.jdbc.SimpleDataSource=debug
log4j.logger.com.ibatis.common.jdbc.ScriptRunner=debug
log4j.logger.com.ibatis.sqlmap.engine.impl.SqlMapClientDelegate=debug
log4j.logger.java.sql.Connection=debug
log4j.logger.java.sql.Statement=debug
log4j.logger.java.sql.PreparedStatement=debug,stdout

热点排行