Solve the problem of struts2 tags misplaced in HTML

Source: Internet
Author: User

By default, form elements are distributed across different rows. The following code:

<s:form action="login2">    <s:textfield label="用户名" name="username"/>    <s:password label="密码" name="password"/>    <s:submit label="提交"/></s:form>

We look at the code above is not much the same as HTML, but because the Struts2 form defaults to a separate row for each element in the form, the label property is just like the text label in HTML that precedes the <input type= "text"/>. If we don't want it to wrap, it should be written in the following format:

<s:form action="login2" theme="simple">    <s:textfield label="用户名" name="username"/>    <s:password label="密码" name="password"/>    <s:submit label="提交"/></s:form>

However, after setting theme= "simple", the label property of the form element will be invalidated, then we have to precede the form element with the text that you want to display with the label. Such as:

<s:form action="login2" theme="simple">      用户名:<s:textfield label="用户名" name="username"/>      密码:<s:password label="密码" name="password"/>    <s:submit label="提交"/></s:form>

Instead of displaying the value in the label, the text in front of the text box is displayed, and the button displays its original default value: Sbumit

Solve the problem of struts2 tags misplaced in HTML

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.