后台:
@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