📄 struts-logic.html
字号:
</td>
</tr>
</table>
</div>
<p>
<a href="#top">Back to top</a>
</p>
<h3 id="present">
<strong>present</strong> -
Generate the nested body content of this tag if the specified
value is present in this request.
</h3>
<div class="indent">
<p>Depending on which attribute is specified, this tag checks the
current request, and evaluates the nested body content of this tag
only if the specified value <strong>is</strong> present. Only one
of the attributes may be used in one occurrence of this tag, unless
you use the <code>property</code> attribute, in which case the
<code>name</code> attribute is also required.</p>
<table class="tag-attributes">
<thead>
<tr>
<th class="attribute">Attribute Name</th>
<th>Description</th>
</tr>
</thead>
<tr class="evenRow">
<td align="center">cookie</td>
<td>
<p>Checks for the existence of a cookie with the specified name.</p>
[RT Expr]
</td>
</tr>
<tr class="oddRow">
<td align="center">header</td>
<td>
<p>Checks for the existence of an HTTP header with the specified
name. The name match is performed in a case insensitive manner.</p>
[RT Expr]
</td>
</tr>
<tr class="evenRow">
<td align="center">name</td>
<td>
<p>Checks for the existence of a JSP bean, in any scope, with the
specified name. If <code>property</code> is also specified, checks
for a non-null property value for the specified property.</p>
[RT Expr]
</td>
</tr>
<tr class="oddRow">
<td align="center">parameter</td>
<td>
<p>Checks for the existence of at least one occurrence of the
specified request parameter on this request, even if the parameter
value is a zero-length string.</p>
[RT Expr]
</td>
</tr>
<tr class="evenRow">
<td align="center">property</td>
<td>
<p>Checks for the existence of a non-null property value, returned
by a property getter method on the JSP bean (in any scope) that is
specified by the <code>name</code> attribute. Property references
can be simple, nested, and/or indexed.</p>
[RT Expr]
</td>
</tr>
<tr class="oddRow">
<td align="center">role</td>
<td>
<p>Checks whether the currently authenticated user (if any) has been
associated with any of the specified security roles. Use a comma-delimited
list to check for multiple roles. Example:
<code><logic:present role="role1,role2,role3">
code.....
</logic:present></code>
</p>
[RT Expr]
</td>
</tr>
<tr class="evenRow">
<td align="center">scope</td>
<td>
<p>The bean scope within which to search for the bean named by the
<code>name</code> property, or "any scope" if not specified.</p>
[RT Expr]
</td>
</tr>
<tr class="oddRow">
<td align="center">user</td>
<td>
<p>Checks whether the currently authenticated user principal has the
specified name.</p>
[RT Expr]
</td>
</tr>
</table>
</div>
<p>
<a href="#top">Back to top</a>
</p>
<h3 id="redirect">
<strong>redirect</strong> - Render an HTTP Redirect</h3>
<div class="indent">
<p>Performs an <code>HttpServletResponse.sendRedirect()</code>
call to the hyperlink specified by the attributes to this
tag. URL rewriting will be applied automatically, to
maintain session state in the absence of cookies.</p>
<p>The base URL for this redirect is calculated based on
which of the following attributes you specify (you must
specify exactly one of them):</p>
<ul>
<li>
<em>forward</em> - Use the value of this attribute as the
name of a global <code>ActionForward</code> to be looked
up, and use the module-relative or context-relative
URI found there.</li>
<li>
<em>href</em> - Use the value of this attribute unchanged.
</li>
<li>
<em>page</em> - Use the value of this attribute as an
module-relative URI, and generate a server-relative
URI by including the context path.</li>
</ul>
<p>Normally, the redirect you specify with one of the
attributes described in the previous paragraph will be left
unchanged (other than URL rewriting if necessary). However,
there are two ways you can append one or more dynamically
defined query parameters to the hyperlink -- specify a single
parameter with the <code>paramId</code> attribute (and its
associated attributes to select the value), or specify the
<code>name</code> (and optional <code>property</code>)
attributes to select a <code>java.util.Map</code> bean that
contains one or more parameter ids and corresponding values.
</p>
<p>To specify a single parameter, use the <code>paramId</code>
attribute to define the name of the request parameter to be
submitted. To specify the corresponding value, use one of the
following approaches:</p>
<ul>
<li>
<em>Specify only the <code>paramName</code> attribute</em>
- The named JSP bean (optionally scoped by the value of the
<code>paramScope</code> attribute) must identify a value
that can be converted to a String.</li>
<li>
<em>Specify both the <code>paramName</code> and
<code>paramProperty</code> attributes</em> - The specified
property getter method will be called on the JSP bean
identified by the <code>paramName</code> (and optional
<code>paramScope</code>) attributes, in order to select
a value that can be converted to a String.</li>
</ul>
<p>If you prefer to specify a <code>java.util.Map</code> that
contains all of the request parameters to be added to the
hyperlink, use one of the following techniques:</p>
<ul>
<li>
<em>Specify only the <code>name</code> attribute</em> -
The named JSP bean (optionally scoped by the value of
the <code>scope</code> attribute) must identify a
<code>java.util.Map</code> containing the parameters.</li>
<li>
<em>Specify both <code>name</code> and
<code>property</code> attributes</em> - The specified
property getter method will be called on the bean
identified by the <code>name</code> (and optional
<code>scope</code>) attributes, in order to return the
<code>java.util.Map</code> containing the parameters.</li>
</ul>
<p>As the <code>Map</code> is processed, the keys are assumed
to be the names of query parameters to be appended to the
hyperlink. The value associated with each key must be either
a String or a String array representing the parameter value(s).
If a String array is specified, more than one value for the
same query parameter name will be created.</p>
<table class="tag-attributes">
<thead>
<tr>
<th class="attribute">Attribute Name</th>
<th>Description</th>
</tr>
</thead>
<tr class="evenRow">
<td align="center">action</td>
<td>
<p>Logical name of a global <code>Action</code> that
contains the actual content-relative URI of the destination
of this transfer. This hyperlink may be dynamically
modified by the inclusion of query parameters, as described
in the tag description. You <strong>must</strong> specify
exactly one of the <code>action</code> attribute, the
<code>forward</code> attribute, the
<code>href</code> attribute,
or the <code>page</code> attribute.</p>
[RT Expr]
</td>
</tr>
<tr class="oddRow">
<td align="center">anchor</td>
<td>
<p>Optional anchor tag ("#xxx") to be added to the generated
hyperlink. Specify this value <strong>without</strong> any
"#" character.</p>
[RT Expr]
</td>
</tr>
<tr class="evenRow">
<td align="center">forward</td>
<td>
<p>Logical name of a global <code>ActionForward</code> that
contains the actual content-relative URI of the destination
of this redirect. This URI may be dynamically
modified by the inclusion of query parameters, as described
in the tag description. You <strong>must</strong> specify
exactly one of the <code>forward</code> attribute, the
<code>href</code> attribute, the <code>linkName</code>
attribute, or the <code>page</code> attribute.</p>
[RT Expr]
</td>
</tr>
<tr class="oddRow">
<td align="center">href</td>
<td>
<p>The URL to which this redirect will transfer control.
This URL may be dynamically modified
by the inclusion of query parameters, as described in the
tag description. You <strong>must</strong> specify
exactly one of the <code>forward</code> attribute, the
<code>href</code> attribute, the <code>linkName</code>
attribute, or the <code>page</code> attribute.</p>
[RT Expr]
</td>
</tr>
<tr class="evenRow">
<td align="center">name</td>
<td>
<p>The name of a JSP bean that contains a <code>Map</code>
representing the query parameters (if <code>property</code>
is not specified), or a JSP bean whose property getter is
called to return a <code>Map</code> (if <code>property</code>
is specified).</p>
[RT Expr]
</td>
</tr>
<tr class="oddRow">
<td align="center">page</td>
<td>
<p>The context-relative path (beginning with a "/"
character) to which this hyperlink will transfer control
if activated. This hyperlink may be dynamically modified
by the inclusion of query parameters, as described in the
tag description. You <strong>must</strong> specify exactly
one of the <code>forward</code> attribute, the
<code>href</code> attribute, the <code>linkName</code>
attribute, or the <code>page</code> attribute.</p>
[RT Expr]
</td>
</tr>
<tr class="evenRow">
<td align="center">paramId</td>
<td>
<p>The name of the request parameter that will be dynamically
added to the generated hyperlink. The corresponding value is
defined by the <code>paramName</code> and (optional)
<code>paramProperty</code> attributes, optionally scoped by
the <code>paramScope</code> attribute</p>
[RT Expr]
</td>
</tr>
<tr class="oddRow">
<td align="center">paramName</td>
<td>
<p>The name of a JSP bean that is a String containing the
value for the request parameter named by <code>paramId</code>
(if <code>paramProperty</code> is not specified), or a JSP
bean whose property getter is called to return a String
(if <code>paramProperty</code> is specified). The JSP bean
is constrained to the bean scope specified by the
<code>paramScope</code> property, if it is specified.</p>
[RT Expr]
</td>
</tr>
<tr class="evenRow">
<td align="center">paramProperty</td>
<td>
<p>The name of a property of the bean specified by the
<code>paramName</code> attribute, whose return value must
be a String containing the value of the request parameter
(named by the <code>paramId</code> attribute) that will be
dynamically added to this hyperlink.</p>
[RT Expr]
</td>
</tr>
<tr class="oddRow">
<td align="center">paramScope</td>
<td>
<p>The scope within which to search for the bean specified
by the <code>paramName</code> attribute. If not specified,
all scopes are searched.</p>
[RT Expr]
</td>
</tr>
<tr class="evenRow">
<td align="center">property</td>
<td>
<p>The name of a property of the bean specified by the
<code>name</code> attribute, whose return value must be
a <code>java.util.Map</code> containing the query parameters
to be added to the hyperlink. You <strong>must</strong>
specify the <code>name</code> attribute if you specify
this attribute.</p>
[RT Expr]
</td>
</tr>
<tr class="oddRow">
<td align="center">scope</td>
<td>
<p>The scope within which to search for the bean specified
by the <code>name</code> attribute. If not specified, all
scopes are searched.</p>
[RT Expr]
</td>
</tr>
<tr class="evenRow">
<td align="center">transaction</td>
<td>
<p>Set to <code>true</code> if you want the current
transaction control token included in the generated
URL for this redirect.</p>
[RT Expr]
</td>
</tr>
<tr class="oddRow">
<td align="center">useLocalEncoding</td>
<td>
<p>If set to <code>true</code>, LocalCharacterEncoding will be
used, that is, the characterEncoding set to the HttpServletResponse,
as prefered character encoding rather than UTF-8, when
URLEncoding is done on parameters of the URL.</p>
[RT Expr]
</td>
</tr>
</table>
</div>
<p>
<a href="#top">Back to top</a>
</p>
</div>
<!--end main-->
</div>
<!--end content-->
<div id="footer">
<img id="powered-logo" alt="Powered by Struts" src="../images/struts-power.gif" />
Copyright (c) 2000-2005, The Apache Software Foundation <span class="noprint">-
<a href="http://wiki.apache.org/struts/StrutsDocComments">Comments?</a>
</span>
</div>
<!--end footer-->
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -