List list = new ArrayList();
while(rs.next()){
Book book = new Book();
book.setId(rs.getInt("id"));
book.setName(rs.getString("name"));
book.setPrice(rs.getDouble("price"));
book.setCount(rs.getInt("count"));
book.setAuthor(rs.getString("author"));
list.add(book);
}
request.setAttribute("list", list);
request.getRequestDispatcher("book_list.jsp").forward(request, response);
<%
List list = request.getAttribute("list");
if (list == null || list.size()
out.print("没有数据");
}else{
for(Book book:list){
%>
<%=book.getId()%>
<%=book.getName()%>
<%=book.getPrice()%>
<%=book.getCount()%>
<%=book.getAuthor()%>
<%
}
}
%>
名称为FindServlet的Servlet的对象将Book集合放置到request中转发到book_list.jsp中,在book_list.jsp中获取Book集合时报错。提示Book cannot be resolved to a type。