- In action, call dao or other helper method to retrieve data for dropdown list
- put the data (list/collection/array) to request or formbean property
- request.setAttribute("cityList", cityHelper.getAllCityLabelValueBean());
- cityListProperty = cityHelper.getAllCityLabelValueBean();
- In JSP
- for request
<html:form action="xxx">
<html:select property="city">
<html:optionsCollection name="dpList" label="label" value="value"/>
OR
<html:options collection="dpList" labelProperty="label" property="value"/>
</html:select>
</html:form>
</html:form>
- for property of formbean
<html:form action="xxx">
<html:select property="city">
<html:optionsCollection property="cityListProperty" label="label" value="value"/>
</html:select>
</html:form>
博客介绍了在Struts框架中处理下拉列表数据的方法。在action里调用dao或其他辅助方法获取下拉列表数据,将数据存入request或formbean属性,如设置cityList。在JSP中,可根据request或formbean属性展示下拉列表。
844

被折叠的 条评论
为什么被折叠?



