springmvc 中的 ModelAndView 遍历其中额的数据 ModelAndView介绍,见链接http://www.cnblogs.com/Sunnor/p/6130380.html 我想要遍历Modelandview中的arraylist是,想使用struts标签遍历,结果是classnotfound 后来查阅资料,是需要用jstl标签遍历,也就解决了 Controller.java @RequestMapping("/admin/showall.do") /** * 获取所有书籍信息,以JSON格式返回 * @return */ public ModelAndView getAll(){ String path="admin/showbooks"; ModelAndView mav=new ModelAndView(path); ArrayList<Book> list=null; list=bookDao.getAll(); mav.addObject("ALLBOOKS", list); return mav; } } jsp页面 <%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%> <%@ taglib prefix="c" uri="http://java./jsp/jstl/core" %> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www./TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>所有图书</title> </head> <body> 显示所有图书。哈哈 <table> <tr><td>序号</td><td>书名</td><td>出版社</td><td>作者</td><td>价格</td> </tr> <c:forEach var="item" items="${ALLBOOKS }" varStatus="status"> <tr><td>${status.index +1}</td><td>${item.name }</td><td>${item.publisher }</td><td>${item.author }</td><td>${item.price }</td></tr> </c:forEach> </table> </body> </html> |
|