org.apache.struts2.components
类 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., &amp;). 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.

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>

 
 

另请参见:
Param

字段摘要
 
从类 org.apache.struts2.components.Component 继承的字段
COMPONENT_STACK
 
构造方法摘要
URL(com.opensymphony.xwork2.util.ValueStack stack, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)
           
 
方法摘要
 boolean end(Writer writer, String body)
          Callback for the end tag of this component.
 String findString(String expr)
          Evaluates the OGNL stack to find a String value.
 UrlProvider getUrlProvider()
           
 void setAction(String action)
           
 void setAnchor(String anchor)
           
 void setEncode(boolean encode)
           
 void setEscapeAmp(boolean escapeAmp)
           
 void setExtraParameterProvider(ExtraParameterProvider provider)
           
 void setForceAddSchemeHostAndPort(boolean forceAddSchemeHostAndPort)
           
 void setIncludeContext(boolean includeContext)
           
 void setIncludeParams(String includeParams)
           
 void setMethod(String method)
           
 void setNamespace(String namespace)
           
 void setPortletMode(String portletMode)
           
 void setPortletUrlType(String portletUrlType)
           
 void setScheme(String scheme)
           
 void setUrlIncludeParams(String urlIncludeParams)
           
 void setUrlRenderer(UrlRenderer urlRenderer)
           
 void setValue(String value)
           
 void setWindowState(String windowState)
           
 boolean start(Writer writer)
          Callback for the start tag of this component.
 
从类 org.apache.struts2.components.ContextBean 继承的方法
setId, setVar
 
从类 org.apache.struts2.components.Component 继承的方法
addAllParameters, addParameter, altSyntax, copyParams, getComponentStack, getParameters, getStack, setActionMapper, setThrowExceptionsOnELFailure, setUrlHelper, usesBody
 
从类 java.lang.Object 继承的方法
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

构造方法详细信息

URL

public URL(com.opensymphony.xwork2.util.ValueStack stack,
           javax.servlet.http.HttpServletRequest req,
           javax.servlet.http.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)
从类 Component 复制的描述
Callback for the start tag of this component. Should the body be evaluated?

覆盖:
Component 中的 start
参数:
writer - the output writer.
返回:
true if the body should be evaluated

end

public boolean end(Writer writer,
                   String body)
从类 Component 复制的描述
Callback for the end tag of this component. Should the body be evaluated again?

NOTE: will pop component stack.

覆盖:
Component 中的 end
参数:
writer - the output writer.
body - the rendered body.
返回:
true if the body should be evaluated again

findString

public String findString(String expr)
从类 Component 复制的描述
Evaluates the OGNL stack to find a String value.

参数:
expr - OGNL expression.
返回:
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)