有关jsp页面动态加载下拉框,显示时id转换name的问题
jsp添加页面下拉框样式
//后台绑定“userlist”
public void selectUser(HttpServletRequest request, HttpServletResponse response) throws Exception {// 下拉框显示员工信息
List<User> list = new ArrayList();
String sql = "SELECT * FROM user";
JdbcUtils jd = new JdbcUtils();
list = jd.select(sql);
request.setAttribute("userList", list);
request.getRequestDispatcher("chuqinAdd.jsp").forward(request,response);
//return list;
}
<li><label>员工</label>
<div class="vocation">
<select class="select1" name="ygname" id="selectid" ">
<option value=''>---请选择---</option>
<c:forEach items="${userList }" var="user">
<option value='${user.user_id}'>${user.user_name}</option>
</c:forEach>
</select>
</div></li>
//jspx修改页面
<li>
<label>
员工
</label>
<label>
<select class="select1" name="ygname" id="selectid" >
<c:forEach items="${userList }" var="user">
<c:if test="${gzMap.yuangong_id==user.user_id}"><option value='${user.user_id}'>${user.user_name}</option></c:if>
</c:forEach>
<c:forEach items="${userList }" var="user">
<option value='${user.user_id}'>${user.user_name}</option>
</c:forEach>
</select>
</label>
</li>
//列表显示页面id转换成name
<td>
<c:forEach items="${userList}" var="user">
<c:if test="${chuqin.yuangong_id==user.user_id}">${user.user_name}</c:if>
</c:forEach>
</td>
<td>