分享

Struts2 鲜为人知的调试技巧(下)

 WindySky 2011-06-30

2 debug=browser(支持IE,火狐,Chrome)

官方文档Debugging Struts提及到一个browser调试模式,按照官方文档的说明把struts2-config-browser-plugin-x.x.x.x.jar放入lib目录。

笔者访问了debug-browser.action的页面代码如下:

<%@ page language="java" contentType="text/html; charset=GBK"%>  
<%@ taglib prefix="s" uri="/struts-tags" %>
<%@ taglib uri="/struts-dojo-tags" prefix="sx"%>
<html>  
  <head>
  <sx:head/> 
  <head>  
  <body>  
        <s:debug/>  
  </body>  
 
<html>

但笔者以常规方式访问http://localhost:8080/uploadFile/process.action的时候打印出了<s:debug/>标签的调试信息,如下图所示


 

当使用参数访问(地址http://localhost:8080/uploadFile/process.action?debug=browser)的时候如下所示:

效果和官方的图示一致。

上图中Expand是展开(节点)的意思。

笔者展开了servlet内置对象application的内容,如图所示:

从此图可以了解到笔者演示环境的Servlet容器版本是“Apache Tomcat/6.0.26”。聪明的你应该能明白笔者想要告诉你的是什么了~~

 

从访问http://localhost:8080/uploadFile/process.actionhttp://localhost:8080/uploadFile/process.action?debug=browser

获得视图分析:加了参数后process.action页面的debug标签信息全部消失了。

总结出debug=browser是为了方便开发者了解当前action的对象信息,

与通过Eclipse等ide调试视图方式查看当前action变量信息具有异曲同工之妙。

process.action代码如下:

<%@ page language="java" contentType="text/html; charset=GBK"%>  
<%@ taglib prefix="s" uri="/struts-tags" %>
<%@ taglib uri="/struts-dojo-tags" prefix="sx"%>
<html>  
  <head>
  <sx:head/> 
  <head>  
  <body>  
        <s:debug/>  
  </body>  
 
<html> 

3 debug=xml(IE、 火狐、Chrome均可用)

访问http://localhost:8080/uploadFile/process.action?debug=xml可获得以xml方式展现的调试信息,具体用途不详。

 

4 其他调试技巧:

1 struts.xml    

<constant name="struts.configuration.xml.reload" value="true"/>

热加载被修改过后的 struts2 配置文件(通常是xml文件)具体用法请查阅网络相关文章

2 JavaRebel 提交Java开发效率

3 tomcat页面编译异常 调试技巧 jsp_precompile=true

 

 

附:

 Struts2 鲜为人知的调试技巧(上)

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多