站内搜索:
首页 >> 前端 >> 内容
freeMark中遍历list集合

时间:2017/4/12 13:50:00

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> 

 

  • 上一篇:angular最佳实践
  • 下一篇:js闭包初探
  • 返回顶部