方法一:
<html:select property="id"> //这里一定不能再用vlue属性了,只用一个property就可以了
<c:forEach var="row" item="${rs.rows}">
<html:option value="row.id">
<c:out value="row.name"/>
</html:option>
</c:forEach>
</html:select>
方法二:
jsp里:
<html:select property="userid">
<html:options collection="userHtmlSelect" property="value" labelProperty="label"/>
</html:select>
ActionForm 里:
private java.lang.String userid="admin"; //默认值
Action里:
form.setUserid("guest");//修改默认值
//设置下拉选项
List rs = new java.util.ArrayList();
rs.add(new org.apache.struts.util.LabelValueBean("管理员",
"admin"));
rs.add(new org.apache.struts.util.LabelValueBean("客人","guest"));
request.getSession().setAttribute("userHtmlSelect",rs);
return mapping.findForward("index");
方法三:
<html:select property= “m_select ” value= “C2 “>
<html:option value= “C1 “> 您的选择1 </html:option>
<html:option value= “C2 “> 您的选择2 </html:option>
<html:option value= “C3 “> 您的选择3 </html:option>
</html:select>