2011-07-02 52 views
2

沒有人有可以在另一個JSP頁面中投進任何web應用程序或包括來自於瀏覽報頭,REQ和會話屬性使用了JSP調試助手頁面?JSP信息頁面調試助手

可以請你分享如果可能的話?這將是許多

回答

5
  • 下降pageDebugger.jsp在你的web應用
  • 訪問包括來自另一個JSP一樣,layout.jsp顯示每一頁上這個細節在表後
  • 此頁面列出
    • 請求參數
    • 頁面作用域屬性和值
    • 請求作用域屬性和值
    • 會話範圍的屬性和值
    • 應用範圍屬性和值的範圍定義
    • 選項來搜索資源的類路徑上
  • 依賴於Spring
  • 請求頭
  • 所有的Spring bean框架是可選刪除它,如果你不使用

pageDebugger.jsp

<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> 
<html> 
<head> 
<style type="text/css"> 
td { 
    word-wrap: break-word; 
} 
</style> 
</head> 
<body> 
<table width="100%" border="1" cellpadding="0" cellspacing="0" 
    style="table-layout: fixed;"> 
    <colgroup> 
     <col width="500"> 
    </colgroup> 
    <tr> 
     <th colspan="2"> 
     <h3>attributes in $paramValues</h3> 
     </th> 
    </tr> 
    <c:forEach var="entry" items="${paramValues}"> 
     <tr> 
      <td><c:out value="${entry.key}" /></td> 
      <td><c:forEach var="item" items="${entry.value}" 
       varStatus="status"> 
       <pre><c:out value="${item}" /></pre> 
       <c:if test="${not status.last}"> 
        <br /> 
       </c:if> 
      </c:forEach></td> 
     </tr> 
    </c:forEach> 
    <tr> 
     <th colspan="2"> 
     <h3>attributes in $requestScope</h3> 
     </th> 
    </tr> 
    <c:forEach var="entry" items="${requestScope}"> 
     <tr> 
      <td><c:out value="${entry.key}" /></td> 
      <td><pre><c:out value="${entry.value}" /></pre></td> 
     </tr> 
    </c:forEach> 
    <tr> 
     <th colspan="2"> 
     <h3>attributes in $sessionScope</h3> 
     </th> 
    </tr> 
    <c:forEach var="entry" items="${sessionScope}"> 
     <tr> 
      <td><c:out value="${entry.key}" /></td> 
      <td><pre><c:out value="${entry.value}" /></pre></td> 
     </tr> 
    </c:forEach> 
    <tr> 
     <th colspan="2"> 
     <h3>attributes in $pageScope</h3> 
     </th> 
    </tr> 
    <c:forEach var="entry" items="${pageScope}"> 
     <tr> 
      <td><c:out value="${entry.key}" /></td> 
      <td><pre><c:out value="${entry.value}" /></pre></td> 
     </tr> 
    </c:forEach> 
    <tr> 
     <th colspan="2"> 
     <h3>attributes in $headerValues</h3> 
     </th> 
    </tr> 
    <c:forEach var="entry" items="${headerValues}"> 
     <tr> 
      <td><c:out value="${entry.key}" /></td> 
      <td><c:forEach var="item" items="${entry.value}" 
       varStatus="status"> 
       <pre><c:out value="${item}" /></pre> 
       <c:if test="${not status.last}"> 
        <br /> 
       </c:if> 
      </c:forEach></td> 
     </tr> 
    </c:forEach> 
    <tr> 
     <th colspan="2"> 
     <h3>attributes in $applicationScope</h3> 
     </th> 
    </tr> 
    <c:forEach var="entry" items="${applicationScope}"> 
     <tr> 
      <td><c:out value="${entry.key}" /></td> 
      <td><pre><c:out value="${entry.value}" /></pre></td> 
     </tr> 
    </c:forEach> 
    <tr> 
     <th colspan="2"> 
     <h3>System Properties</h3> 
     </th> 
    </tr> 
    <tr> 
     <th>Key</th> 
     <th>Value</th> 
    </tr> 
    <%@page import="java.util.Map"%> 
    <%@page import="java.util.Set"%> 
    <%@page import="java.util.Properties"%> 
    <%@page import="java.util.Arrays"%> 
    <% 
     Properties p = System.getProperties(); 
     Set<Map.Entry<Object, Object>> set = p.entrySet(); 
     for (Map.Entry<Object, Object> e : set) { 
    %> 
    <tr> 
     <td><%=e.getKey()%></td> 
     <td><%="".equals(e.getValue()) ? "&nbsp;" : e.getValue()%></td> 
     <% 
      } 
     %> 
    </tr> 
    <tr> 
     <th colspan="2"> 
     <h3>Spring Beans</h3> 
     </th> 
    </tr> 
    <%@page import="org.springframework.web.context.WebApplicationContext"%> 
    <%@page 
     import="org.springframework.web.context.support.WebApplicationContextUtils"%> 
    <%@page import="org.springframework.core.io.Resource"%> 
    <% 
     try { 
      WebApplicationContext springContext = WebApplicationContextUtils 
        .getWebApplicationContext(config.getServletContext()); 
      if (springContext != null) { 
       String[] beanNames = springContext.getBeanDefinitionNames(); 
       Arrays.sort(beanNames); 
       for (String beanName : beanNames) { 
        String className = springContext.getType(beanName) 
          .getName(); 
    %> 
    <tr> 
     <td><%=beanName%></td> 
     <td><%=className%></td> 
    </tr> 
    <% 
     } 
    %> 
    <tr> 
     <th colspan="2"> 
     <h3>Spring Resources</h3> 
     </th> 
    </tr> 
    <tr> 
     <th colspan="2"> 
     <form><input name="resources" size="50"/></form> 
     </th> 
    </tr> 

    <% 
     String resourceNames = request.getParameter("resources"); 
       if (resourceNames != null) { 
        Resource[] resources = springContext 
          .getResources(resourceNames); 
        for (Resource r : resources) { 
    %> 
    <tr> 
     <td><%=r.getFilename()%></td> 
     <td><%=r.getURI()%></td> 
    </tr> 
    <% 
     } 
       } 
      } 
     } catch (Exception e) { 
      e.printStackTrace(); 
     } 
    %> 


</table> 
</body> 
</html> 

此外,如果你有選項來修改web.xml文件,看看這些是也可用於監測/型材活動HTTP會話屬性

http://code.google.com/p/sessionmon/

http://messadmin.sourceforge.net/

+0

最後! thx,使我的一天 – TecHunter

0

有很大的幫助。在工作中,我已經使用JDeveloper來從IDE運行在調試模式下的應用程序。您可以將斷點插入到.jsp中並查看所有調試信息。雖然,我不是jdeveloper的忠實粉絲,但它是IDE的一個很好的功能。頁面直接或