List中值是null,不知道怎麼取到值。。。
JAVA CODE:
List listBrand = new ArrayList();
while(rs.next()){
BrandVO brand = new BrandVO();
brand.setId(rs.getInt("id"));
brand.setBname(rs.getString("name"));
listBrand.add(brand);
}
req.setAttribute("carList", rs.getInt("id"));
req.getRequestDispatcher("add_car.jsp").forward(req, resp)
jsp中代碼:
<%
List<BrandVO> listBrand = (List) request.getAttribute("carList");
for(BrandVO brand : listBrand){
%>
<option><%=brand.getBname()%></option>
<% }%>
看樣子你是使用的迭代器啊,你的rs中有值嗎?先打個斷點看看