...
Used for Action Chaining | |
Used for web resource integration, including JSP integration | |
Used for FreeMarker integration | |
Used to control special HTTP behaviors | |
Used to redirect to another URL (web resource) | |
Used to redirect to another action mapping | |
Used to stream an InputStream back to the browser (usually for file downloads) | |
Used for Velocity integration | |
Used for XML/XSLT integration | |
Used to display the raw content of a particular page (i.e jsp, HTML) | |
Used to provide Tiles 2 integration | |
Used to provide Tiles 3 integration | |
Used to postback request parameters as a form to the specified destination | |
JSON Result | Used to serialize actions into JSON |
Optional
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 | ||
---|---|---|
| ||
<result type="freemarker">foo.fm</result>
|
That is the equivalent to this:
Code Block | ||
---|---|---|
| ||
<result type="freemarker">
<param name="location">foo.vm</param>
</result>
|
...
All Result Types are plugged in via the Result Configuration.
Extending
You can always extend defined result types and implement whatever logic you need. To simplify process of that, you can define your custom ResultFactory
and use it with connection with custom interface which your Result implements. Check Define dedicated factory to see how to do it.
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 | ||||
---|---|---|---|---|
| ||||
public class MyResult extends ServletDispatcherResult implements ParamNameAwareResult {
public boolean acceptableParamName(String name, String value) {
return "accept".equals(name);
}
}
|
and then register it and use instead of default dispatcher
result.