js獲取freemarker變量的值

後臺數據javascript

@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裏面的idjava

前臺js能夠這麼寫數組

<script type="text/javascript">

$(document).ready(function() {
       var checkedArray =[];
       //初始化將測試集包含的用例存在數組裏面
       <#if testCaseDtoList??>
            <#list testCaseDtoList as item>
                 checkedArray.push("${item.id}");
            </#list>
       </#if>
});

</script>

頁面初始化以後就可使用checkedArrayapp

完美!測試

相關文章
相關標籤/搜索