@RequestMapping("/index") public String intoIndex(Model a) { Package aPackage = this.getClass().getPackage(); a.addAttribute("time","2019-12-11"); return "index"; }
<html xmlns:th="http://www.w3.org/1999/xhtml"> <head> <title>HTML 页面</title> </head> <body> <p>body</p> <p>---------------------------------------------</p> <input type="text" th:value="${time}" id="staff_name2"/> </body> </html> <!-- 获取model 中传过来的model 值 --> <script th:inline="javascript"> var single = [[${time}]]; console.log(single) </script> <script> var single = [[${time}]]; console.log(single) </script>