Struts2 表单元素 [英] Struts2 form elements

查看:30
本文介绍了Struts2 表单元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么当我在 s:textfield 之间插入一个元素时,它会被放置在顶部?有没有办法解决这个问题?感谢您对此提供帮助.

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>

浏览器上显示的订单:

test1
test2
First Name
Last Name
Address
Email

推荐答案

我想我对这个问题的回答来得太晚了,但我对此做出回应只是为了记录.

I guess my answer to this question comes too late, but I respond to this just for the record.

文本元素没有出现在两者之间的原因是,struts 渲染了一个表格来显示您的输入字段(及其标签).如果您查看由 struts 呈现的 HTML,您将看到每个文本字段都有一个标签.如果在它们之间插入任何其他组件,struts 将不知道如何将它们格式化到表单的表格中,从而导致在表格开始之前显示项目.为了避免这种行为,您可以将表单的主题"属性设置为简单".这将导致您需要自己进行所有格式化.

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.

希望这会有所帮助.

这篇关于Struts2 表单元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆