使用Struts 2开发应用05:程序调试

文章翻译自Struts 2官方文档

现代IDE提供了优秀的程序调试支持。此外,框架提供了在运行时查看框架对象的支持。

调试拦截器提供了三种洞察页面背后的数据的调试模式。xml模式用XML文档格式化相关的框架对象。console模式提供了一个接受运行时表达式的OGNL命令行,browser模式添加一个显示来自值栈(Value Stack)的对象的交互页面。

为了使用调试功能,首先确保struts.devMode的值已经通过struts.properties文件或struts.xml文件设置为了true,像这样:

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

然后,当页面需要调试时,在URL上添加?debug=xml或者?debug=console或者?debug=browser

- <debug>
  <parameters /> 
- <context>
- <struts.actionMapping>
  <class>class org.apache.struts2.dispatcher.mapper.ActionMapping</class> 
  <name>showcase</name> 
  <namespace>/</namespace> 
  </struts.actionMapping>
  <attr /> 
  <__devMode>true</__devMode> 
  <report.conversion.errors>false</report.conversion.errors> 
  </context>
  <request /> 
  <session /> 
- <valueStack>
- <value>
  <actionErrors /> 
  <actionMessages /> 
  <class>class com.opensymphony.xwork2.ActionSupport</class> 
  <errorMessages /> 
  <errors /> 
  <fieldErrors /> 
- <locale>
  <ISO3Country>USA</ISO3Country> 
  <ISO3Language>eng</ISO3Language> 
  <class>class java.util.Locale</class> 
  <country>US</country> 
  <displayCountry>United States</displayCountry> 
  <displayLanguage>English</displayLanguage> 
  <displayName>English (United States)</displayName> 
  <displayVariant /> 
  <language>en</language> 
  <variant /> 
  </locale>
  </value>
- <value>
  <class>class com.opensymphony.xwork2.DefaultTextProvider</class> 
  </value>
  </valueStack>
  </debug>

对于?debug=xml,使用Internet Explorer浏览器或者在FireFox中使用IE标签

对于?debug=console,你可能需要放宽任意的弹出阻断。

猜你喜欢

转载自a2429854489.iteye.com/blog/2285590