今天在springboot+thymeleaf项目中,用thymeleaf模板引入js文件。
<script src="webjars/jquery/3.3.1-1/jquery.js"></script> <script src="../static/js/register.js" th:src="@{/static/js/register.js}"></script>
然后js文件的函数没触发,路径引入没有问题。
并且 application.properties
spring.mvc.static-path-pattern=/static/**
配置文件也设置好了。
那么问题出在哪里了了?
原来我是在 HTML的 head标签里面引入的,后面查询资料得知 javascript的性能优化才知道
把 引入js文件script语句,放在body标签最后面。