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