<html:optionsCollection 怎么用字符数组? 要这么麻烦吗?还不如自己做一个TAG! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 使用<html:optionsCollection>标签 1)在ActionForm中加入字段 private List cityList=new ArrayList(); 2)加入必须的getter方法 public List getCityList() { return cityList; } 3)在reset方法内给cityList填充内容 cityList.add(new LabelValueBean("北京市","010")); cityList.add(new LabelValueBean("广州市", "020")); cityList.add(new LabelValueBean("上海市", "021")); 4)JSP标签中使用 <html:select property="city2"> <html:optionsCollection property="cityList" label="label" value="value"/> </html:select> <html:form action="" > <html:select property="tt" > <logic:iterate id="bbc" name="array"> <option value="${bbc}"><bean:write name="bbc"/></option> </logic:iterate> </html:select> </html:form> 怎么都搞的这么麻烦。。如果数组是Form的一个属性就用<html:options property=""/>如果是用request.setAttribute()放在request里的就用<html:options name=""/> <html:form action="" > <html:select property="tt" > <logic:iterate id="bbc" name="array"> <option value="${bbc}"><bean:write name="bbc"/></option> </logic:iterate> </html:select> </html:form>这个方案不错 do c/s or b/s??? 用JDBC的话,怎么能得到SQL server的字段属性呢?? 结合IronTrack SQL和P6Spy监控SQL性能的出现的问题 获得路径问题 关于用多态取代条件判断(if/swith)得问题? 最近在看一个框架Romaframework,希望跟人交流 给几个好的j2ee学习网站? Struts下内置对象 request 的问题 [算法]将字符串转换为树形结构,标题要长 xstream.fromXML转换错误 怎样让weblogic实现热布署 不重起weblogic清除服务器缓存问题
1)在ActionForm中加入字段
private List cityList=new ArrayList();
2)加入必须的getter方法
public List getCityList() {
return cityList;
}
3)在reset方法内给cityList填充内容
cityList.add(new LabelValueBean("北京市","010"));
cityList.add(new LabelValueBean("广州市", "020"));
cityList.add(new LabelValueBean("上海市", "021"));
4)JSP标签中使用
<html:select property="city2">
<html:optionsCollection property="cityList" label="label" value="value"/>
</html:select>
<html:select property="tt" >
<logic:iterate id="bbc" name="array">
<option value="${bbc}"><bean:write name="bbc"/></option>
</logic:iterate>
</html:select>
</html:form>
如果数组是Form的一个属性就用<html:options property=""/>
如果是用request.setAttribute()放在request里的就用<html:options name=""/>
<html:select property="tt" >
<logic:iterate id="bbc" name="array">
<option value="${bbc}"><bean:write name="bbc"/></option>
</logic:iterate>
</html:select>
</html:form>
这个方案不错