After the Action processes the request, a result is selected to provide the response. A result may simply forward to a HTML page, or a JavaServer page, a FreeMaker or Velocity template, or the result might construct a PDF or some other complex report. There may be multiple results available to an action mapping. To indicate which one to select, the Action class returns a name corresponding to the appropriate result.
<action name="Logon" class="tutorial.Logon"> <result name="input">/tutorial/Logon.jsp</result> <result type="redirect-action">HelloWorld</result> </action>
In the Hello World lesson, our results used the default type, Dispatcher
. The Dispatcher
forwards to another web resource. Other kinds of views can be used by specifying a different result type.
The Logon mapping uses a different return type for "success" (the default result code). The redirect-action
takes the name of an Action as a parameter, and then issues a client-side redirect to the new action. As a result, the URI on the browser's location bar will change.
Summary
The framework offers a variety of result types. An Action can select the appropriate result by name, without actually knowing what result type will be rendered. If a result can be used by multiple action mappings, it can be defined once as a global result.
For more, see Result Types.
Next |
|
---|---|
Prev |