Struts 多重选择框正确设置
我有一个多重选择框,根据先前输入的信息填充该框,然后可以进行选择。现在它正在填充,但不是按照我想要的方式填充。
在我的 JSP 中,它设置为:
<html:select property="fields" multiple="true" style='width:200px;'>
<html:options property="fields"/>
</html:select>
在我的 Form 类中,“字段”是一个 ArrayList,在我的 Action 类中,我也添加了值。我想要做的是将这些值作为该框的选择,然后能够读取用户从该框中选择的任何值。现在看来,这些值被放入其中,但也被“选择”。我想我所拥有的只是需要一些调整,但我有点困惑。
感谢您的帮助
I have a multiple select box, which upon previous information entered is populated and then selections can be made. Right now it is being populated but not in the exact way as I intended.
In my JSP it is setup as:
<html:select property="fields" multiple="true" style='width:200px;'>
<html:options property="fields"/>
</html:select>
In my Form class "fields" is an ArrayList that in my Action class I add values too. What I want to be able to do is have those values be the choices for the box, and then be able to read whatever values the user selects from that box. It seems right now that the values are being put in there but are also being "selected". I figure what I have will just need some tweaking but I'm a little confused.
Thanks for the help
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我能够让这个部分工作:
其中 fieldsOptions 是我在 Action 类中添加值的 ArrayList,而 fields 是我表单中的 String[] ,我现在的问题是在我选择我希望能够看到这些的选项之后我认为它们只会被放入“字段”中,但情况似乎并非如此,我可能只是没有正确访问它。
I was able to get this partway working:
Where fieldsOptions is an ArrayList I add values to in my Action class, and fields is a String[] in my form, my problem now is after I select options I want to be able to see these selections and I assumed they would just be put in "fields" but it doesnt seem that is the case, am I maybe just not accesting it right.