wenson 发表于 2013-1-27 06:25:47

在Struts的html:select标签中显示默认值

最近在写一个系统中,有一个有下拉列表的修改资料功能,对Struts的html:select进行了运用。
其中怎么样使进入修改页面之后,该下拉列表里的数据是该需要修改的数据列的数据字段,也就是使html:select中显示的值默认对应数据库中的值。测试修改了一个下午,总得不出结果,最后还是看了Struts的examples才算是弄出来了,如:
<html:select property="id"><c:foreach item="rs.rows" var="row"><html:option value="row.id">       </html:option>   </c:foreach>    </html:select>          <html:select property="c_id"></html:select>    
<div class="code_title"><div class="dp-highlighter"><div class="bar">   
[*]<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>         
页: [1]
查看完整版本: 在Struts的html:select标签中显示默认值