Learn the Form-related labels provided by Struts.

Source: Internet
Author: User

Learn the Form-related labels provided by Struts.
Continue to learn about the HTML Tag library provided by Struts. By Budi Kurniawan
In the first part of this series, I will show you how to use the HTML Tag library provided by Struts to configure a Struts application. I also introduced a type of tag in the tag Library: Independent tags. In the second part, I will continue to introduce the second type of labels: The labels related to form. The form-related labels include the <form> label and all the labels that must be included in the label. For example, the <text> and <password> labels are form-related labels, because they are meaningless if they are not put in a form.
<Form> label
<Form> A tag is used to generate an HTML form. Many rules must be followed when using this label.
First, the <form> tag must contain an action attribute, which is the only required attribute in the tag. If this attribute is not available, the JSP page throws an exception. You must specify a valid value for this action attribute. A valid value is the access path of any <action> sub-element in the <action-mappings> element in the Struts configuration file of the application. The corresponding <action> element must have a name attribute. Its value is the name of form bean. For example, if you have a <form> label:
<Html: form action = "/login">
The <action-mappings> element in your Struts configuration file must contain the following <action> element in bold:
<Action-mappings>
<Action path = "/login"
Type = "com. javapro. struts. LoginAction"
Name = "loginForm"
Scope = "request"
Input = "/login. jsp">
<Forward name = "success" path = "/mainMenu. jsp"/>
</Action>
</Action-mappings>
This means that a form tag is associated with form bean.
Another rule to be followed is: any labels (<text>, <password>, In addition to the attributes mentioned above, the <form> tag has some attributes that are not mandatory but are better "secondary. For example, you can use the focus attribute to generate JavaScript, which will "focus" on an element contained in the form. You need to specify the element name for the focus attribute. For example, the following code is fixed on the second Text element:

Related Article

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.