如何编写动态struts <html:option>
,我正在做如下
<logic:iterate id="data" name="sendEmailForm" property="eventList">
<html:option value="<bean:write name="data" property="eventId"/>"/>
<bean:write name="data" property="title"/>
</html:option>
</logic:iterate>
但是收到以下错误:
JSPG0069E:解析jsp时找到不匹配的结束标记。期待 逻辑:迭代在[87,130]
找到html:选项
还有另一种方法吗?
提前致谢。
答案 0 :(得分:3)
<html:option property="title">
<html:optionsCollection name="sendEmailForm" label="title" value="eventId" />
<html:option>
property="?"
无论你想设置什么,如果属性是标题和相应的方法(getTitle()
,setTitle(String title)
),那么property= "title"
name = "?"
您在请求/会话属性中添加的内容
像(request Or session).setAttribute("sendEmailForm", ListArr);
然后name =“sendEamilForm”
listArr
是bean的对象数组(可能是formbean或简单的pojofile / bean)。 label ="?"
您希望展示的内容,如果您有属性'title'
和
然后是相应的setter(setTitle(String title)
)和getter(getTitle()
)方法
label="title"
value ="?"
您希望将哪个值作为选项中的值。你打电话给你的getter方法
相应的属性,如果你有属性eventId和方法(
setEventId(String eventId) , getEventId()
)然后value="eventId"
答案 1 :(得分:0)
好吧最后我在下面找到了解决方案
<html:optionsCollection name="sendEmailForm" property="eventList" label="title" value="eventId" />