Java -Struts 1.2 组合框问题
我正在使用java(Struts 1.2)。我的第一页是登录页面。成功登录后,将显示第二页。第二页包含一个表单,其中一个字段是组合框。我希望应该填充此组合框,以便用户可以选择该选项。
我尝试了很多方法,例如使用 html:option collections 和 html:optionsCollections 等,但它显示错误,例如找不到 bean 。
任何人都可以给我一个示例工作代码吗?
谢谢
I am using java (Struts 1.2). My first page is a login page. After a successful login, the second page is displayed The second page contains a form in which one of the fields is a combo box. I want this combo box should be filled so that the user can select the option.
I have tried many methods, like using html:option collections, and html:optionsCollections etc. but it is showing errors like bean not found.
Can any body give me a sample working code.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
使用html标签需要在html:form中并且两者必须有一个关联的bean,你在struts.xml中配置它。
The use of html tag required to be in html:form and that both must have an associated bean, you configure it in struts.xml.
html:select 上的属性是表单中的属性,当用户从组合框中选择某些内容时,该属性将被填充。
--- 抱歉无法格式化它以清楚地显示代码
The property on html:select is the one in your form which will be filled when the user selects something from the combobox.
--- sorry couldn't format it to show the code clearly
我可以告诉您的是:
LoginAction
),让您的操作转发到另一个将填充您的列表的操作。request.setAttribute("contents", list)
。现在将您的页面转发到 JSP 文件。content
(存储在request.setAttribute
方法中)并执行以下操作:示例:
有关 Struts 的更多信息 HTML TagLib。
What I can tell you is this:
LoginAction
in this example), let your action forward to another action which will populate your list.request.setAttribute("contents", list)
. Now forward your page to a JSP file.contents
(as stored inrequest.setAttribute
method) and do something of this effect:Example:
More information on Struts HTML TagLib.