result"
m (correct highlight (via JWB)) |
|||
(One intermediate revision by one other user not shown) | |||
Line 34: | Line 34: | ||
[Allowed: forward, redirect, error, done] | [Allowed: forward, redirect, error, done] | ||
[Default: forward] | [Default: forward] | ||
− | [since 1.0 | + | [since 1.1.0] |
− | It specifies the type of result. By default, it is < | + | It specifies the type of result. By default, it is <code>foward</code>. If you prefer ''send-redirect'' (i.e., <code>HttpServletResponse.sendRedirect</code>), you could specify the type as <code>redirect</code>, and the URI must be an URL that the user is allowed to access, i.e., it can't be located in <code>/WEB-INF</code>. |
− | If a result represents an error, you could specify the type as < | + | If a result represents an error, you could specify the type as <code>error</code>, and put the error code in the element, such as |
<source lang="xml"> | <source lang="xml"> | ||
Line 45: | Line 45: | ||
</source> | </source> | ||
− | If the action generates the output directly to the response, you could specify the type as < | + | If the action generates the output directly to the response, you could specify the type as <code>done</code>, then ZEST won't handle it further but returning the response directly. |
=Version History= | =Version History= | ||
Line 52: | Line 52: | ||
! Version !! Date !! Content | ! Version !! Date !! Content | ||
|- | |- | ||
− | | 1.0 | + | | 1.1.0 |
| June 2011 | | June 2011 | ||
| Three new types, redirect, error and done, were introduced. | | Three new types, redirect, error and done, were introduced. |
Latest revision as of 02:57, 18 January 2022
Syntax:
<result [name="a-result"] [type="forward|redirect"]>a-view's-uri</result> <result [name="a-result"] type="error">error-code</result> <result [name="a-result"] type="error">error-code: error-message</result> <result [name="a-result"] type="done"/>
It specifies a result of an action definition. It must be placed under the action element, and an action definition could have one or multiple results.
The result consists of the name, the type, and the URI of the targeted view. The name, if any, is specified as the name attribute, while the URI of the view is specified as the inner text of the result element. For example,
<result name="success">/WEB-INF/hello/HelloWorld.jsp</result>
<result>/WEB-INF/foo/Foo.jsp</result><!-- the default view -->
<result name="success2" type="redirect">/somewhere/to/go</result>
<result name="notfound" type="error">404</result>
Attributes
name
[Optional] [Default: null]
It specifies the name of the result. The view specified in a result is used, if the result's name matches the return value of the execute method.
If the name attribute is omitted, it is the default result. In other words, the URI of the view is used if no other result is matched.
type
[Optional] [Allowed: forward, redirect, error, done] [Default: forward] [since 1.1.0]
It specifies the type of result. By default, it is foward
. If you prefer send-redirect (i.e., HttpServletResponse.sendRedirect
), you could specify the type as redirect
, and the URI must be an URL that the user is allowed to access, i.e., it can't be located in /WEB-INF
.
If a result represents an error, you could specify the type as error
, and put the error code in the element, such as
<result name="notfound" type="error">404</result>
<result name="gone" type="error">301: moved</result>
If the action generates the output directly to the response, you could specify the type as done
, then ZEST won't handle it further but returning the response directly.
Version History
Version | Date | Content |
---|---|---|
1.1.0 | June 2011 | Three new types, redirect, error and done, were introduced. |