SpringBoot獲取Model值


后台:

@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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM