Strutes2 Tag URL

Source: Internet
Author: User

The URL tag is used to create a URL.

You can use the PARAM tag in the label body to provide additional request parameters. If the Value property of the Param tag is an array or iterator, then all values will be appended to the URL.

Property:

Name Required Default Evaluated Type Description
Action False False String The action to generate the URL for, if not using value
Anchor False False String The anchor for this URL
Encode False True False Boolean Whether to encode parameters
Escapeamp False True False Boolean Specifies whether to escape ampersand & to &amp or not
Forceaddschemehostandport False False False Boolean Specifies whether to force the addition of scheme, host and port or not
Id False False String Deprecated. Use ' var ' instead
Includecontext False True False Boolean Whether actual context should be included in URL
Includeparams False None False String The Includeparams attribute may has the value ' none ', ' get ' or ' all '
Method False False String The method of action to use
Namespace False False String The namespace to use
Portletmode False False String The resulting portlet mode
Portleturltype False False String Specifies if this should is a portlet render or action URL. Default is "Render". To create a action URL, use "action".
Scheme False False String Set Scheme attribute
Value False False String The target value to use, if not using action
Var False False String Name used to reference the value pushed into the value Stack
WindowState False False String The resulting Portlet window state

Remark :

(1) If both action and value are specified, the URL will be generated first using the value of the Value property;

(2) If neither the action nor the value attribute is specified, the URL of the current page will be used;

(3) The default value of the Escapeamp property is true, so the request parameter will be delimited (that is, &amp) with Escape and number &. This is intended to be consistent with XHTML, however, when using the property tag to output URL tags to generate urls, the Escapeamp attribute should be set to false to prohibit the escape of the number &;

(4) The default value of the Includecontext property is true, which is to include the context path of the Web application in the build URL, but behaves differently when used with the action and value properties of the tag.

When used with the Action property, the generated URL always contains the context path;

When used with the Value property, if the Value property starts with a slash (/) (For example:/ Urltag.action), the resulting URL will contain the context path, and if the Value property specifies a relative path (for example: urltag.action), the resulting URL will not contain a context path;

(5) If the value of the Includeparams property is get, the generated URL will contain the parameters for the GET request submission, and if the value is all, the generated URL also contains the parameters for the post request submission, and if you do not want the generated URL to contain any user-submitted request parameters, Then you can set this property to none.

Example :

generate a URL using the current page URL<s:url/> Use the value of the Namepsace and Action property to generate the URL<s:url action= "Urltag" namespace= "/A /b "> Force Add Schema, host, and Port <s:url value=" urltag.action "using the Forceaddschemehostandport property Forceaddschemehostandport= "true"/> set the Includeparams property to True to append request parameters <s:url value= "using nested param tags " Urltag.action "includeparams=" None ">    <s:param name=" id "value=" 1 "/></s:url>  Use the ID property and the Escapeamp property to generate a URL after the URL label ends using the properties label output<s:url value= "urltag.action" id= "Urltag" escapeamp= "false" > <s:param name= "id" value= "1"/>
<s:param name= "Code" value= "2"/></s:url><s:property value= "#urlTag"/>

Note:

(1) The request parameters appended with the nested PARAM tags are given precedence over the user-submitted request parameters, so if the original request parameter has the same name, it will be overwritten;

(2) When the id attribute is specified, the resulting URL is saved to Ognlcontext, and the resulting URL is: urltag.action?id=1&amp;code= by setting the Escapeamp property to false to suppress the escape of the number & 2, the browser is displayed as: urltag.action?id=1&code=2.

If you set the Escapeamp property to True (the default), the resulting URL is: urltag.action?id=1&amp;amp;code=2, which appears in the browser as urltag.action?id=1&amp; code=2.

Strutes2 Tag URL

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.