...
Code Block | ||
---|---|---|
| ||
<result-types>
<result-type name="dispatcher" default="true"
class="org.apache.struts2.dispatcher.ServletDispatcherResult" />
</result-types>
|
If a type
attribute is not specified, the framework will use the default dispatcher
type, which forwards to another web resource. If the resource is a JavaServer Page, then the container will render it, using its JSP engine.
...
In most cases if an action returns an unrecognized result name this would be a programming error and should be fixed.
Multiple names
It is possible to define multiple names for the same result:
Code Block | ||
---|---|---|
| ||
<action name="save">
<result>success.jsp</result>
<result name="error, input">input-form.jsp</result>
</action> |
Such functionality was added in Struts 2.5
Global Results
Most often, results are nested with the action element. But some results apply to multiple actions. In a secure application, a client might try to access a page without being authorized, and many actions may need access to a "logon" result.
...
See Parameters in configuration results for an expanded discussion.
Returning Result Objects
Instead of configuring results and returning the name, it is possible to return a result object:
Code Block | ||
---|---|---|
| ||
public Result runAction() { ServletDispatcherResult result = new ServletDispatcherResult(); result.setLocation("input-form.jsp"); return result; } |