做数据修改时让select选择框自动选中对应的项
做修改时在logic标签里怎么让select选择框自动选中对应的项。。?
也没有好人给段代码看看-。-
<logic:iterate id= "user " name= "user "
type= "org.hibernate.bean.User ">
<OPTION
value= " <bean:write name= "user " property= "userid "/> ">
<bean:write name= "user " property= "username " />
</OPTION>
</logic:iterate>
------解决方案--------------------可以这样做,将应该选中的项显示于列表的第一项,然后迭代显示其他项(这里需要判断不为第一项即可),假如你要修改的bean为theUser,它已经存到了request中
<select name= "userid ">
<option value= ' <bean:write name= "theUser " property= "userid "/> '> <bean:write name= "theUser " property= "username "/> </option>
<logic:iterate id= "user " name= "userList "
type= "org.hibernate.bean.User ">
<logic:notEqual name= "user " property= "userid " value= ' <%=((User)request.getAttribute( "theUser ")).getUserid().toString()%> '>
<OPTION
value= ' <bean:write name= "user " property= "userid "/> '>
<bean:write name= "user " property= "username " />
</OPTION>
</logic:notEqual>
</logic:iterate>
</select>