...
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
<action name="helloName2" class="tutorial.HelloName2"> <result name="success">helloName2>HelloName2-success.jsp</result> <result name="error">helloName>HelloName-error.jsp</result> </action> |
So far, our results have 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.
Configuring Result Types
The actionstruts-default
package defines result types for the Results Result classes provided with the framework. If your package uses a custom result type, you can add it to your package.types.
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
<xwork> <include name="struts-default.xml"/> <package name="default" extends="struts-default"> <result-types> <result-type name="imageImage" class="tutorial.ImageResult" /> </result-types> <action name="imageImage" class="tutorial.ImageActionImage"> <result name="success" type="imageImage"/> </action> </package> </xwork> |
...
It's not unusual for mappings to share a need for the same result. For example, if your application is securedsecure, then many mappings might need to return "login" if the security check fails. Rather than define a common result in every action mapping, the framework lets you define global results.
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
<package name="default" extends="webworkstruts-default"> <global-results> <result name="login" type="redirect-action">login</result> <result name="unauthorized">/unauthorized>Unauthorized.jsp</result> </global-results> <!-- other package declarations --> </package> |
...