<span th:text="${name}"></span>
JavaScript获取
var msg = [[${msg}]];
如下文解决了问题
https://blog.csdn.net/m0_52613676/article/details/112383781