Struts2 form tag theme attributes

Source: Internet
Author: User

In struts2, theme attributes include XHTML, HTML, simple, and Ajax. The default is XHTML.

Theme: Set the topic of the struts2 tag. The default value is XHTML. When theme = XHTML: Additional Tr and TD are generated by default. Theme = simple: generate the HTML tag format corresponding to the tag.

By default, form elements are distributed across different rows. The following code:
<S: Form Action = "login2"> <s: textfield label = "username" name = "username"/> <s: password label = "password" name = "password"/> <s: Submit label = "Submit"/> </S: Form>
We can see that the above Code is not much different from HTML, but because the struts2 form divides every element in the form into a single row by default, the label attribute is the same as the text label before <input type = "text"/> in HTML. If we don't want it to wrap automatically, we should write it in the following format:

<S: Form Action = "login2"Theme = "simple"> <S: textfield label = "username" name = "username"/> <s: Password label = "password" name = "password"/> <s: submit label = "Submit"/> </S: Form>

HoweverTheme = "simple"The label attribute of the form element is invalid. In this case, you must add the text you want to display with the label before the form element. For example:

<S: Form Action = "login2"Theme = "simple"> Username: <s: textfield label = "username" name = "username"/> password: <s: Password label = "password" name = "password"/> <s: submit label = "Submit"/> </S: Form>

In this case, the text in front of the text box is displayed instead of the value in the label. The button displays its original default value: sbumit.

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: 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.