Struts2 表单元素
为什么当我在 s:textfield 之间插入一个元素时,它会被放置在顶部? 有办法解决这个问题吗? 感谢您对此提供帮助。
<s:textfield label="First Name" required="true"/>
<s:textfield label="Last Name" required="true"/>
<s:text name="testing1">test1</s:text>
<s:textfield label="Address" required="false"/>
<s:textfield label="Email" required="true"/>
<s:text name="testing2">test2</s:text>
浏览器上显示的订单:
test1
test2
First Name
Last Name
Address
Email
Why is it that when I insert an element in between the s:textfield it gets placed on top?
Is there a way to fix that?
Thanks for helping on this.
<s:textfield label="First Name" required="true"/>
<s:textfield label="Last Name" required="true"/>
<s:text name="testing1">test1</s:text>
<s:textfield label="Address" required="false"/>
<s:textfield label="Email" required="true"/>
<s:text name="testing2">test2</s:text>
Order being displayed on browser:
test1
test2
First Name
Last Name
Address
Email
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我想我对这个问题的回答来得太晚了,但我的回答只是为了记录。
文本元素不出现在中间的原因是因为struts 呈现一个表格来显示您的输入字段(及其标签)。如果您查看由 struts 呈现的 HTML,您将看到每个文本字段都有一个标记。如果在它们之间插入任何其他组件,struts 将不知道如何将它们格式化到表单的表格中,从而导致项目在表格开始之前显示。
为了避免这种行为,您可以将表单的“主题”属性设置为“简单”。这将导致您需要自己完成所有格式化。
希望这有帮助。
I guess my answer to this question comes too late, but I respond to this just for the record.
The reason why the text elements don't appear in between is because struts renders a table to display your input fields (and their labels). If you look at the HTML rendered by struts you will see one tag for each textfield. If you insert any other component between these, struts will not know how to format these into the table of the form, resulting in the items being displayed before the start of the table.
To avoid this behavior you can set the "theme" attribute of the form to "simple". This will result in the fact that you will need to do all formatting by yourself.
Hope this helps.