日期:2014-05-20 浏览次数:20869 次
//我的action获取从数据获取了城市的列表,是从city表中取的,就id,cityname俩个字段 int id =Integer.parseInt(request.getParameter("id")); List citylist=cityDao.findAll(); User user=userDao.findId("id"); request.setAttribute("User", user); request.setAttribute("cityList", citylist); return mapping.findForward("update"); //我有个用户表,有个字段是城市,就是根据页面的城市下拉框取值的, //现在在页面如何让它加载修改页面的时候,城市列表就是我之前选择的那个值,而不是“请选择” <select name="User.city"> <c:forEach items="${requetsScope.cityList}" var="city"> <option value="${city.cityname}"> ${city.cityname } </option> </c:forEach> <c:if test="{User.city==city.cityname}"> <option value="${city.cityname}" selected> ${city.cityname } </option> </c:if> </select>
conn.close(); rs.close(); smt.close();
------解决方案--------------------
[code=Java]
<select name= "User.city ">
<c:forEach items= "${requetsScope.cityList} " var= "city ">
<c:if test= "{User.city!=city.cityname} ">
<option value= "${city.cityname} ">
${city.cityname }
</option>
</c:if>
<c:if test= "{User.city==city.cityname} ">
<option value= "${city.cityname} " selected>
${city.cityname }
</option>
</c:if>
</c:forEach>
</select>
[/code]
------解决方案--------------------
http://blog.csdn.net/APOLLO_TS/archive/2009/09/19/4569135.aspx
------解决方案--------------------
<c:if test="{User.city==city.cityname}"></c:if>
是不是这个地方 改成这样试试???
<c:if test="{User.city.cityname==city.cityname}"></c:if>
哎
------解决方案--------------------
jstl ${User.city.cityname eq city.cityname } eq
------解决方案--------------------
<select name="User.city">
<c:forEach items="${requetsScope.cityList}" var="city">
你单词 写错了。。。 requestScope.cityList
------解决方案--------------------
细节呀。。。。。。。
------解决方案--------------------
[Quote=引用:]
<c:forEach items= "${requetsScope.cityList} " var= "city ">