Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3
Info

The example code for this tutorial, debugging_struts, is available for checkout at https://svngithub.apache.org/repos/asf/struts/sandbox/trunk/struts2examples/Image Removedcom/apache/struts-examples.

Introduction

During development of a Struts 2 web application you may want to view the information being managed by the Struts 2 framework. This tutorial will cover two tools you can use to see how Struts 2 views your web application. One tool is the Struts 2 configuration plugin and the other is the debugging interceptor. This article also discusses how to set the log level to see more or fewer log messages.

...

Code Block
html
html
1Link For Configuration Browser

<a href="<s:url action="index" namespace="config-browser" />">Launch the configuration browser</a>

...

Clicking on the link for the configuration browser will cause the Struts 2 framework to return this page to your browser.
Image Removed Image Added

You can click on an action link to see the configuration for that action. For example clicking on the register action link results in this.

...

Using the Debugging Interceptor

If you have set devmode devMode to true (in the example application see struts.xml) then one of the interceptors that is activated when Struts 2 processes an action is the DebuggingInterceptor. The DebuggingInterceptor looks for a query string appended to the action URL with a name of debug and a value of xml, console, command, or browser.

If the DebuggingInterceptor finds that query string then it will halt further execution of the action and instead return to the browser debugging information. The format of the returned information depends on the value of the debug query parameter. See debugginginterceptor DebuggingInterceptor for more detail.

In the example application on the index.jsp is a link for displaying debugging information. This link includes the query string debug=browser. If you click on this link you'll see a table with columns that can be expanded and collapsed. The table contains the various objects and their state being managed by the Struts 2 framework.

...

The Struts 2 framework will write to a log a great deal of information if you've configured the log properties to log at the debug level. In the example application, view log4j.xml. The two major packages involved in the Struts 2 framework, com.opensymphony and org.apache.struts2, are configured to write debug and above log messages. When you run the application view the standard out for your Servlet container to see all the information written to the log. Please check Logging page for other options.

Summary

Using the configuration browser plugin and the debugging interceptor can assist you in trouble shooting a problem with a Struts 2 web application. These tools should only be used in development.

...