1. 程式人生 > >js獲取freemarker變量的值

js獲取freemarker變量的值

test type doc servle ret method read 需要 mod

後臺數據

@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

完美!

js獲取freemarker變量的值