Home > Guides > Tag Developers Guide > Struts Tags > Tag Reference > Generic Tag Reference > url

Please make sure you have read the Tag Syntax document and understand how tag attribute syntax works.

The id attribute is deprecated in Struts 2.1.x, and has been replaced by the var attribute.


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.


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.


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.

Setting a default value for includeParams

The property struts.url.includeParams can be used to set the default value of the includeParams attribute.

Setting the default value of includeParams
   <constant name="struts.url.includeParams" value="none" />

See Constant Configuration for further information.

As of Struts 2.1.3 the includeParams constant defaults to "none".


Dynamic Attributes Allowed:








actionfalsefalseStringThe action to generate the URL for, if not using value
anchorfalsefalseStringThe anchor for this URL
encodefalsetruefalseBooleanWhether to encode parameters
escapeAmpfalsetruefalseBooleanSpecifies whether to escape ampersand (&) to (&amp or not
forceAddSchemeHostAndPortfalsefalsefalseBooleanSpecifies whether to force the addition of scheme, host and port or not
includeContextfalsetruefalseBooleanWhether actual context should be included in URL
includeParamsfalsenonefalseStringThe includeParams attribute may have the value 'none', 'get' or 'all'
methodfalsefalseStringThe method of action to use
namespacefalsefalseStringThe namespace to use
portletModefalsefalseStringThe resulting portlet mode
portletUrlTypefalsefalseStringSpecifies if this should be a portlet render or action URL. Default is "render". To create an action URL, use "action".
schemefalsefalseStringSet scheme attribute
valuefalsefalseStringThe target value to use, if not using action
varfalsefalseStringName used to reference the value pushed into the Value Stack
windowStatefalsefalseStringThe resulting portlet window state