js获取freemarker变量的值

后台数据

@RequestMapping(value="/suit_item", method = RequestMethod.GET)
    public String getSuitItem(HttpServletRequest request, ModelMap map) {

    //TO DO
    map.put("testCaseDtoList", testCaseDtoList);
    return "/suit/suit_item";
}

需要获取一个list里面的id

前台js可以这么写

<script type="text/javascript">

$(document).ready(function() {
       var checkedArray =[];
       //初始化将测试集包含的用例存在数组里面
       <#if testCaseDtoList??>
            <#list testCaseDtoList as item>
                 checkedArray.push("${item.id}");
            </#list>
       </#if>
});

</script>

页面初始化之后就可以使用checkedArray

完美!

posted @ 2017-06-27 14:01  乱码出黑客  阅读(21160)  评论(1编辑  收藏  举报