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