Struts tag-html

Source: Internet
Author: User

Struts HTML tags have the same functions as standard HTML tags. We recommend that you use struts tags in struts applications because these tags can be closely linked with other components of the Struts framework, such

1)
Generate element. This label has a lang attribute used to display the language used by the user. When setting Wei true, the tag will first output the language of the number of web pages based on the locale object stored in the current httpsession. If there is no httpsession or there is no locale object in it, the language will be output based on the attribute of the HTTP request header, if the HTTP Request Header does not exist, the language is output based on the default locale.


2)

3)

4)
Generate the user request URI, which is used to output the URL part of the hyper-connection, but does not generate html


5)

According to my personal views, I feel that struts is really good, but there are some areas where good things are not practical, as is Java. I recommend the above methods.

1) create a Global Forwarding connection: first configure it in the struts configuration file

Reference in JSP page:

2) create a complete URL Connection, that is, you can connect to other sites.

3) connect to another webpage of the same application from one webpage

4) method for adding request parameters to a URL or Rui

5) method for adding a single request variable to a URL or Uri

Pagemproperty> action

The paramid attribute specifies the request parameter name, The paramname attribute specifies the variable name, And the paramproperty specifies the attribute of the variable Wei JavaBean.

After studying the basic labels of the strutshtml label library, we will start to study an important topic, Struts form tag, its sub-tag, single-choice button, check box, drop-down list, and so on, the following is a detailed introduction:

1)

2)
The property attribute of the text tag specifies the name of the field, which matches an attribute in actionform. This is a subtag of the form tag and can submit the value entered by the user to a specific actionform.


3)
The label generates a Cancel button in the form. When the user presses the cancel button, a cancel event is generated, which is captured by the action. How to Deal with execute () in the action class () method programming is mainly used when the user presses the submit button and does not want to submit the request before it is sent.


4)
The label is used to generate the reset button, similar to the above Cancellation button implementation

Reset

, Replacing HTML code .


5)
Click the button to generate and submit tags. The code is written in the same way as Reset:




Submit

.

6)
Tags generate hidden fields on the form to store information that you do not want to see or are not allowed to modify on the form. Its Attributes are similar
Text tag. The property corresponds to the specific attribute in actionform. If you want to display a value in the form and do not want to modify it, you can use this method.


7)
The tag generates a standard HTML check box on the form. For example, if the attribute in actionform is Boolean, only two values are allowed. This label can be used in the form. it mainly uses the property to set the corresponding actionform attribute and a value attribute to set the value of the check box selected by the user. The default value is true, that is to say, when value = false is used, if the user does not select this check box, the actionform attribute is set to Wei true. In order to check the box to work properly, it must be in the reset () of actionform () method. When the value attribute is true, the corresponding attribute must be set to false in the reset () method.


8)
Labels and
The difference is that it can generate check boxes. Its performance ratio is similar.
More flexible, you can dynamically determine the number of checked check boxes, as long as the property attributes are the same, and the value attribute is different, it can correspond to the same array of actionbean. in addition, the checkbox can only correspond to the attribute of the blooean type, while the multibox is unlimited.


9)
Tags indicate multiple single-choice buttons.
Tags can be used in combination.


10)

Tag generation drop-down list or multiple-choice list. The important attribute is the size attribute, which specifies the number of optional items displayed on each webpage. the Multiple Attribute specifies whether multiple choices are supported. If it is set to true, the multi-choice list is displayed. The default value is false. the property corresponds to an attribute in actionform, which is used to store the value selected by the user in the list. in the case of single choice, the corresponding attribute of actionform is defined as a simple type and cannot be an array. if multiple options are selected, the type is array.

The above is a brief description of the form series labels and sub-labels of the strutshtml label library. These labels are not always commonly used, so you can understand them. It is OK to master several commonly used labels. next we will take a look at file upload, which refers to uploading local files to the Web server through user browsing.

The TAG provides the ability to upload files from HTML forms. This tag is also a sub-tag of the form tag, so it must be nested in


The tag is used to output error messages. The actionmessages or its subclass actionerrors set object is found in the request and session range. read the actionmessage object from the actionmessages collection object and display the error message text contained in the actionmessage object on the webpage. the specific error text messages are stored in resourcebundle, and
Tags can recognize HTML elements in error text, such.
Tags can be stored anywhere on the webpage or in the form. the output error is irrelevant to the location of the webpage. its specific attribute is. 1) Name: Specifies the attribute key of the actionmessages object. The tag processing class uses this key to check the actionmessages collection object in the request or session range. 2) Property: Specifies the message attributes. If this parameter is not set, all message objects in the actionmessages collection objects are displayed. actionmessage.3) Bundle: Specifies resourcebundle. If this parameter is not set, the message will be retrieved from the default resourcebundle in the application.


Labels and
The tag can also output messages on the webpage. The specific attribute is: 1) Name: Specifies the attribute key of the actionmessages object, tag processing retrieves the actionmessages object within the request or session range based on this key. 2) message: Specifies the message source. If it is true, the attribute key is globals from the request or session range. the specific actionmessages object of message_key. 3) ID: used to retrieve each actionmessages object from the message set. The name attribute of the tag matches.

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.