struts2开启调试模式的几种方式

1.开启调试模式:
  <constant name="struts.devMode" value="true"></constant>
2.调试方式:
  2.1 使用标签调试:
    在要调试的jsp页面body下,使用<s:debug></s:debug>标签,运行时即可在页面看到一个debug链接。点击进去可查看valueStack的所有信息
  2.2 使用url后缀方式:
    在每个要请求的url地址后面,添加参数:debug=xml 或 debug=console 或debug=browser
    xml表示debug结果展示为xml格式输出,console表示以控制台文本方式输出,browser需要dojo插件支持
  2.3 使用Profiling拦截器测试性能
  a.Profiling拦截器不属于默认的拦截器栈,需配置:
        <action name="debug" class="xxx.xxx.DebugAction">
            <interceptor-ref name="profiling"></interceptor-ref>
            <interceptor-ref name="defaultStack"></interceptor-ref>    
            <result name="success">/index.jsp</result>
        </action>
  b.然后在每个要调试的url地址后添加参数:profiling=true 或 profiling=yes

参考官方文档:

Modern IDEs provide excellent support for debugging. In addition, the framework provides support for inspecting framework-specific objects at runtime.

The Debugging Interceptor provides three debugging modes to provide insight into the data behind the page. The xml mode formats relevant framework objects as an XML document. The console mode provides a OGNL command line that accepts entry of runtime expressions, and the browser mode adds an interactive page that display objects from the Value Stack (it requires the Dojo Plugin)

To use the debugging, first be sure that struts.devMode is set to true is enabled through the struts.properties file or struts.xml file, like:

<constant name="struts.devMode" value="true" />

Then, whenever a page needs debugging, add ?debug=xml or ?debug=console or ?debug=browser to the URL.

For ?debug=xml use Internet Explorer or an IE tab in FireFox
For ?debug=console you may need to relax any popup blockers

 

 

posted on 2013-04-07 10:04  qinxike  阅读(1117)  评论(0编辑  收藏  举报

导航