我正在使用Thymeleaf作为模板引擎。如何将变量从Spring模型传递给JavaScript变量?
春季:
@RequestMapping(value = "message", method = RequestMethod.GET)
public String messages(Model model) {
model.addAttribute("message", "hello");
return "index";
}
客户端:
<script>
....
var m = ${message}; // not working
alert(m);
...
</script>