您的位置:首页 > 编程语言 > Java开发

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

2016-03-23 10:31 531 查看

文章翻译自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
,你可能需要放宽任意的弹出阻断。

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: