后台:

@GetMapping("/globalVerify")
    public String globalVerify(Model model) {
        String rep_id = System.currentTimeMillis() + "";
        model.addAttribute("repId", rep_id);
        list=xxx;
        model.addAttribute("list", list);
        return "m_report";
    }

1、在JavaScript中获取Model值
var repId = [[${rep_id}]]; //这个还可

var repId = '${repId}';【垃圾方法,根本就不能用,坑人!】

2、在thymleaf中获取Model值

// th:each="i:${list}"
<table th:each="i:${list}">
<tr>
<td>Id</td>
<td th:text="${i.getId()}"></td>
</tr>
<td>Name</td>
<td th:text="${i.getName()}"></td>
</tr>
</table>

参考:https://blog.csdn.net/qq_34037264/article/details/103056303

posted on 2022-04-21 01:41  西伯尔  阅读(1010)  评论(0编辑  收藏  举报