核心提示:freeMark中遍历list集合1、controller中@RequestMapping(value=index,method=RequestMethod.GET) public ModelAndV...
freeMark中遍历list集合
1、controller中 @RequestMapping(value="index",method=RequestMethod.GET) public ModelAndView userIndex(ModelMap map) { List list = new DBoperator().findAllTable(); List<Tables> tables = new ArrayList(); for (int i = 0; i < list.size(); i++) { Tables table = new Tables(); table.setTableName(list.get(i).toString()); tables.add(table); } map.put("tables", tables);//传到前台的Tables类型的list集合 return new ModelAndView("user/index"); } 2、ftl中 <h1 align="center">导出报表为PDF文档</h1> <table class="table table-striped table-hover table-bordered" id="editable-sample"> <thead> <tr> <th>tableName</th> </tr> </thead> <tbody> <#list tables as tb> <tr class=""> <td><a href='ExportPDFServlet?tableName=${tb.tableName?default('未设置')}'>${tb.tableName?default('未设置')}</a></td> </tr> </#list> </tbody> </table>