重生之焚尽八荒女主:Struts2 鲜为人知的调试技巧(下)
来源:百度文库 编辑:九乡新闻网 时间:2024/04/27 19:41:48
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"%>
但笔者以常规方式访问http://localhost:8080/uploadFile/process.action的时候打印出了
当使用参数访问(地址http://localhost:8080/uploadFile/process.action?debug=browser)的时候如下所示:
效果和官方的图示一致。
上图中Expand是展开(节点)的意思。
笔者展开了servlet内置对象application的内容,如图所示:
从此图可以了解到笔者演示环境的Servlet容器版本是“Apache Tomcat/6.0.26”。聪明的你应该能明白笔者想要告诉你的是什么了~~
从访问http://localhost:8080/uploadFile/process.action和http://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"%>
3 debug=xml(IE、 火狐、Chrome均可用)
访问http://localhost:8080/uploadFile/process.action?debug=xml可获得以xml方式展现的调试信息,具体用途不详。
4 其他调试技巧:
1 struts.xml
热加载被修改过后的 struts2 配置文件(通常是xml文件)具体用法请查阅网络相关文章
2 JavaRebel 提交Java开发效率
3 tomcat页面编译异常 调试技巧 jsp_precompile=true
附:
Struts2 鲜为人知的调试技巧(上)