Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Chain Result

Used for Action Chaining

Dispatcher Result

Used for web resource integration, including JSP integration

FreeMarker Result

Used for FreeMarker integration

HttpHeader Result

Used to control special HTTP behaviors

Redirect Result

Used to redirect to another URL (web resource)

Redirect Action Result

Used to redirect to another action mapping

Stream Result

Used to stream an InputStream back to the browser (usually for file downloads)

Velocity Result

Used for Velocity integration

XSL Result

Used for XML/XSLT integration

PlainText Result

Used to display the raw content of a particular page (i.e jsp, HTML)

Tiles 2 Result

Used to provide Tiles 2 integration

Tiles 3 Result

Used to provide Tiles 3 integration

Postback Result

Used to postback request parameters as a form to the specified destination

JSON ResultUsed to serialize actions into JSON

Optional

JasperReports Plugin

Used for JasperReports Tutorial integration

Optional, third-party plugin

...

To minimize configuration, Results can be configured with a single value, which will be converted into a parameter, and each Result can specify which parameter this value should be set as. For example, here is a result defined in XML that uses a default parameter:

Code Block
langxml

<result type="freemarker">foo.fm</result>

That is the equivalent to this:

Code Block
langxml

<result type="freemarker">
  <param name="location">foo.vm</param>
</result>

...

Struts 2 provides one such extension for you: ParamNameAwareResult interface when used with StrutsResultBuilder can limit parameters assigned to the result. So you can simple extend existing result with such a functionality as below:

Code Block
java
java

public class MyResult extends ServletDispatcherResult implements ParamNameAwareResult {

    public boolean acceptableParamName(String name, String value) {
        return "accept".equals(name);
    }

}

...