freemark动态加载列表数据

来源:互联网 发布:如何优化页面响应速度 编辑:程序博客网 时间:2024/04/29 10:12
1.ftl页面中 <table  class="table table-striped table-hover table-bordered" name="record"  id="editable-sample"> </table> function pay_details(game_id){      $("[name='record']").html(""); //获取上面table的name,清空table    $.post('${basePath}/agency/pay_details.shtml',{        "game_id":game_id    },function(result){        var html_="";        var html__="";        html_=html_+        "<thead >"+        "<tr>"+            "<th>游戏ID</th>"+            "<th>充值人</th>"+            "<th>游戏用户名</th>"+            "<th>金额</th>"+            "<th>兑换率</th>"+            "<th>充值金币</th>"+            "<th>订单号</th>"+            "<th>充值时间</th>"+            "<th>支付状态</th>"+            "<th>充值状态</th>"+            "<th>充值类型</th>"+        "</tr>"+    "</thead>";        $.each(result, function(idx, obj) {            html__=html__+             "<tr>"+        "<td>"+obj.GameID+"</td>"+        "<td>"+obj.TrueName+"</td>"+        "<td>"+obj.UserName+"</td>"+        "<td>"+obj.PayMoney+"</td>"+        "<td>"+obj.ExchangeRate+"</td>"+        "<td>"+obj.InMoney+"</td>"+        "<td>"+obj.OrderID+"</td>"+        "<td>"+obj.AddTime+"</td>"+        "<td>"+(obj.PaySuccess=='true'? '已支付' :'未支付')+"</td>"+        "<td>"+(obj.InSuccess=='true'? '已充值' : '未充值')+"</td>"+        "<td>"+obj.TypeInfo+"</td>"+    "</tr>";        });        $("[name='record']").html(html_+html__);//把固定行和动态遍历的行加载到table中    });}2.controller中提供List数据 @RequestMapping(value = "pay_details", method = RequestMethod.POST)    @ResponseBody    public List<Map<String, String>> pay_details(HttpServletRequest request) {        List<Map<String, String>> si = new ArrayList<Map<String, String>>();        if (request.getParameter("game_id") != null && request.getParameter("game_id") != "") {            // 发送 POST 请求            String game_id = request.getParameter("game_id").toString();            String sr = RequestService.sendPost(InterfaceAddressConfig.get("GetOrderList"),                    "game_id="+ game_id                    + "&pageSize=900000&pageIndex=1");// 请求充值成功的conditions=1为充值成功,每页90w条            HashMap<String, String> stringToMap = StringToMap.StringToMap(sr);            if (!"[]".equals(stringToMap.get("list").toString())) {                String replace = stringToMap.get("list").toString().replace("[", "").replace("]", "");                String[] arr = replace.split("\\},\\{");                List<String> list = java.util.Arrays.asList(arr);                for (String list_ : list) {                    String lists = "{" + list_.replace("{", "").replace("}", "") + "}";                    System.out.println(lists);                    HashMap<String, String> itemMap = StringToMap.StringToMap(lists);                    si.add(itemMap);                }            }        }        return si;    }

0 0
原创粉丝点击