<%
String users[] =
{ "Bob", "Robert", "Roberto", "Bobby"};
pageContext.setAttribute("users", users);
%>
<html:form action="select−user.do" method="POST">
<table border="0" width="100%">
<tr>
<td
<html:select property="userList" size="4"
multiple="true">
<html:options name="users"
labelName="users"/>
</html:select>
</td>
</tr>
</table>
<html:submit>Save</html:submit>
<html:form>users[] 换成从数据库中取
String users[] =
{ "Bob", "Robert", "Roberto", "Bobby"};
pageContext.setAttribute("users", users);
%>
<html:form action="select−user.do" method="POST">
<table border="0" width="100%">
<tr>
<td
<html:select property="userList" size="4"
multiple="true">
<html:options name="users"
labelName="users"/>
</html:select>
</td>
</tr>
</table>
<html:submit>Save</html:submit>
<html:form>users[] 换成从数据库中取
解决方案 »
- 高分求助:使用javamail包为什么会打印邮件内容到控制台?,有答案马上结贴!
- 初学者的疑惑!用jsp实现成功登陆后延迟登陆并弹出一个小窗口
- List ArrayList
- TOMCAT里"host-manager does not exist or is not a readable directory"错误信息如何解决啊?
- org.hibernate.MappingException: could not instantiate id generator
- IIS+JSP服务器怎么架设?
- JMF播放MP3的问题
- tomcat安装问题
- 虾米是鸡兔意意啊?
- 帮帮忙吧!
- jboss能否支持自增长字段? 如何支持?
- JButton 中文字如何分行显示?急!急!急!急!
一般的传统的标签是这样子的。
<html: select property="yourchoice" size="4">
<html:option value="2">温州地区终端</html:option>
<html:option value="3">宁波地区终端</html:option>
<html:option value="4">杭州地区终端</html:option>
</html:select>这个啊,你可以在 forward这个也叶面之前,在request里面设置yourchoic,如果多选就 设置type="java.lang.String[]"; initial="2 4" ;如果你象这个列表也是动态的,那就用 labelProperty 标签属性
<html:options collection="queryList" property="yourchoice" labelProperty="yourselectedfromdb"/>
当然也是在forward这个页面之前的request里设置。
好久不用struts了,大致就是这样,你试试
selected="selected" 我希望是4或者2我怎么能够动态的显示啊
<select name="group_id" size="20">
<option value="2">温州地区终端</option>
<option value="3">宁波地区终端</option>
<option value="4">杭州地区终端</option>
<option value="1" selected="selected">所有终端</option>
</select>
在Action里面,把查到的结果装到一个ArrayList里面
如:ArrayList cityCollection = new ArrayList();
cityCollection.add(new LabelValueBean(xxx,yyy));//xxx为label,yyy为value
…
request.setAttribute("cityCollection",cityCollection);
…
再在jsp里面:
<html:select…>
<html:options collection="cityCollection " property="value" labelProperty="label"/>
</html:select>
就可以了。当然也可以用<logic:iterate>这个标签。
<html:select>
<logic:iterate id="cityCollection " name="option">
<option value='<bean:write property="value" name="option"/>'><bean:write property="label" name="option"/></option>
</logic:iterate>
<logic:iterate id="cityCollection " name="option">
应为
<logic:iterate id="cityCollection " id="option">
<html:options collection="cityList" property="id" labelProperty="cityName">
</html:select>
就可以动态显示哪个被选中了。
能够给我个提示吗