Struts provides five tag libraries, namely: HTML, Beans, Logic, Template, and Nested.
Tag Library |
Description |
HTML tags |
Used to create HTML input forms that interact with the Struts framework and other corresponding HTML tags |
Bean Label |
used when accessing JavaBeans and its properties, and defining a new bean |
Logic Label |
Managing the output generated by conditions and the loops generated by the set of objects |
Template Label |
As the Tiles frame package appears, this tag has started to reduce the use of |
Nested Label |
Enhance the ability to use other Struts tags for nesting |
common features of labelsStruts label with fixed attribute name:
Property |
Description |
Id |
Name of the script variable when the custom label was created. |
Name |
Indicates a keyword value under which an existing bean can be found. If the scope attribute is given, it is only found in scope. Otherwise, look in various scopes according to the Standard Order: (page, request, session, or application). |
Property |
Indicates a property in the bean in which the value can be retrieved. If not indicated, the value of the object itself is used. |
Scope |
Defines the range (page, request, session, or application) in which the Bean is searched. If no indication is found in order. The script variable (see ID) is created in the same scope. |
The Struts tab also supports nested references, such as:
Property= "Foo.bar.baz"
This is equivalent to making the following call: Getfoo (). Getbar (). Getbaz ();
Or as a setter: Getfoo (). Getbar (). Setbaz (value); |
Although the Struts label was designed to avoid the use of scriptlet, the scriptlet expression is also available to all Struts tags. But make sure you use the full expression:
Html
Tag Library1. It has two attributes: Locale and XHTML, both of which are not required.
After this line of code resolves: |
2. Note: The resulting results depend on the locale of the server on which the Struts application resides. If you deploy the application to a different locale server, you do not need to change the code, locale will automatically adjust. 3. <base> Tags: represents the absolute position of the included page. This tag is only valid if it is embedded in the head tag.
After this line of code resolves: <base href=/"http://www.mymain.com/myStrutsApp/testing.jsp/" > |
4. Label
The most important property page: The path to the image file, preceded by a slash.
Other properties: Heignt, Width, alt.
5. <link> Label
After this line of code resolves: <a href=/"/index.html/" >click demo</a> |
6. <errors> Tags: with a simple Description: This tag looks for reserved key in the Properties collection of the Request object. If it finds a reserved key, it assumes that the key is a string, or a string array
(It contains the message keys found in the module's messageresources, or an object of type Org.apache.struts.action.ActionErrors.)
If the appropriate information exists in the application resources, you can use the following optional message keys:
· Errors.header or Errors.prefix: the appropriate information is displayed before a separate list of error messages.
· Errors.footer or Errors.suffix: The corresponding information is displayed after a separate list of error messages. 7. <form> Label Series
Some rules must be followed when using <form> label: 1. The label must contain an action attribute, which is the only required property in the label. If this property is not available, the JSP page throws an exception. You must then specify a valid value for this action attribute. A valid value is the access path to any of the child elements in the element in the Struts configuration file for the application. and the corresponding element must have a name attribute, whose value is the form bean.
If you have one of these tags ; , then the elements of your Struts configuration file must have an element that appears bold as follows: <action-mappings> <action path=/"/login/" &NBSP; type=/" com.javapro.struts.loginaction/" name=/" loginForm/" scope=/"request/" input=/"/ login.jsp/"" <forward name=/"success/" path=/" mainmenu.jsp/"/> </action> . . </action-mappings> //This is to say that a form label is associated with a form bean. |
2.3. Any label that is included in <form> to receive user input (<text>, <password>, <form> tags There are some "secondary" attributes that are not necessarily but useful.
For example, you can use the focus attribute to generate JavaScript, which is "fixed" (focal) to an element contained in the form. You need to specify the name of the element when you use the Focus property.
<body> User Name: <br>password: <br></body>
After code parsing: <body> <form name=/"loginform/" method=/"post/" action=/"/mystrutsapp/login.do/" > User Name: <input type=/"text/" name=/"username/" value=/"/" > <br>password: <input type=/"text/" name=/"password/" value=/"/" > <br><input type=/"submit/" value=/"submit/" > </form> <script language=/"javascript/" type=/"text/javascript/" > <!-- if (document.forms[/"loginform/"].elements[/"password/"].type!=/"hidden/") document.forms[/"loginform/"].elements[/"password/"].focus () --> </script>
</body> |
<