org.apache.struts2.components
Class URL
java.lang.Object
org.apache.struts2.components.Component
org.apache.struts2.components.ContextBean
org.apache.struts2.components.URL
public class URL
- extends ContextBean
This tag is used to create a URL.
You can use the <param> tag inside the body to provide
additional request parameters. If the value of a param is an Array or
an Iterable all the values will be added to the URL.
NOTE:
By default request parameters will be separated using escaped ampersands (i.e., &).
This is necessary for XHTML compliance, however, when using the URL generated by this tag
with the <s:property> tag, the escapeAmp attribute should be used to disable
ampersand escaping.
NOTE:
When includeParams is 'all' or 'get', the parameter defined in a <param>
tag will take precedence over any params included due to the includeParams attribute. For
example, in Example 3 below, if there is a id parameter in the url where the page this
tag is included like http://<host>:<port>/<context>/editUser.action?id=3333&name=John
the generated url will be http://<host>:<port>/<context>/editUser.action?id=22&name=John
because the parameter defined in the param tag will take precedence.
- action (String) - (value or action choose either one, if both exist value takes precedence) action's name (alias)
-
- value (String) - (value or action choose either one, if both exist value takes precedence) the url itself
- scheme (String) - http scheme (http, https) defaults to the scheme this request is in
- namespace - action's namespace
- method (String) - action's method name, defaults to 'execute'
- encode (Boolean) - url encode the generated url. Defaults to 'true'.
- includeParams (String) - The includeParams attribute may have the value 'none', 'get' or 'all'. Defaults to 'get'.
none - include no parameters in the URL
get - include only GET parameters in the URL (default)
all - include both GET and POST parameters in the URL
- includeContext (Boolean) - Specifies whether to include the web app context path. Defaults to 'true'.
- escapeAmp (Boolean) - Specifies whether to escape ampersand (&) to (&) or not. Defaults to 'true'.
- portletMode (String) - The resulting portlet mode.
- windowState (String) - The resulting portlet window state.
- portletUrlType (String) - Specifies if this should be a portlet render or action URL.
- forceAddSchemeHostAndPort (Boolean) - Specifies whether to force the addition of scheme, host and port or not.
Examples
<-- Example 1 -->
<s:url value="editGadget.action">
<s:param name="id" value="%{selected}" />
</s:url>
<-- Example 2 -->
<s:url action="editGadget">
<s:param name="id" value="%{selected}" />
</s:url>
<-- Example 3-->
<s:url includeParams="get">
<s:param name="id" value="%{'22'}" />
</s:url>
- See Also:
Param
Fields inherited from class org.apache.struts2.components.ContextBean |
var |
Methods inherited from class org.apache.struts2.components.Component |
addAllParameters, addParameter, altSyntax, altSyntax, completeExpressionIfAltSyntax, copyParams, determineActionURL, determineNamespace, end, fieldError, findAncestor, findString, findStringIfAltSyntax, findValue, findValue, findValue, getComponentStack, getParameters, getStack, popComponentStack, setActionMapper, setThrowExceptionsOnELFailure, stripExpressionIfAltSyntax, stripExpressionIfAltSyntax, toString, usesBody |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
LOG
private static final Logger LOG
urlProvider
private UrlProvider urlProvider
urlRenderer
private UrlRenderer urlRenderer
URL
public URL(ValueStack stack,
HttpServletRequest req,
HttpServletResponse res)
setUrlIncludeParams
public void setUrlIncludeParams(String urlIncludeParams)
setUrlRenderer
public void setUrlRenderer(UrlRenderer urlRenderer)
setExtraParameterProvider
public void setExtraParameterProvider(ExtraParameterProvider provider)
start
public boolean start(Writer writer)
- Description copied from class:
Component
- Callback for the start tag of this component.
Should the body be evaluated?
- Overrides:
start
in class Component
- Parameters:
writer
- the output writer.
- Returns:
- true if the body should be evaluated
end
public boolean end(Writer writer,
String body)
- Description copied from class:
Component
- Callback for the end tag of this component.
Should the body be evaluated again?
NOTE: will pop component stack.
- Overrides:
end
in class Component
- Parameters:
writer
- the output writer.body
- the rendered body.
- Returns:
- true if the body should be evaluated again
findString
public String findString(String expr)
- Description copied from class:
Component
- Evaluates the OGNL stack to find a String value.
- Overrides:
findString
in class Component
- Parameters:
expr
- OGNL expression.
- Returns:
- the String value found.
getUrlProvider
public UrlProvider getUrlProvider()
setIncludeParams
public void setIncludeParams(String includeParams)
setScheme
public void setScheme(String scheme)
setValue
public void setValue(String value)
setAction
public void setAction(String action)
setNamespace
public void setNamespace(String namespace)
setMethod
public void setMethod(String method)
setEncode
public void setEncode(boolean encode)
setIncludeContext
public void setIncludeContext(boolean includeContext)
setPortletMode
public void setPortletMode(String portletMode)
setWindowState
public void setWindowState(String windowState)
setPortletUrlType
public void setPortletUrlType(String portletUrlType)
setAnchor
public void setAnchor(String anchor)
setEscapeAmp
public void setEscapeAmp(boolean escapeAmp)
setForceAddSchemeHostAndPort
public void setForceAddSchemeHostAndPort(boolean forceAddSchemeHostAndPort)
Copyright © 2000-2010 Apache Software Foundation. All Rights Reserved.