SpringBoot导入静态文件

版权声明:欢迎转载大宇的博客,转载请注明出处: https://blog.csdn.net/yanluandai1985/article/details/88418749

        SpringBoot一般使用的是Thymeleaf模版。而静态资源一般放在了static目录下面。

        现在的系统的目录是这样的。

        

        在页面中这样导入即可。导入的时候,使用 th:href 的 @{ } 格式进行导入。如下图所示。

        模板在templates下面,js文件在static下面,在模板中引用时不需要加static这个路径。 

       在模板中引用jquery.min.js, 你引用的地址应当为/jquery.js,换成thymeleaf的属性则应当为th:src=”@{/jquery.min.js}”

        

        参考文章:https://blog.csdn.net/qq_32523369/article/details/78782160

猜你喜欢

转载自blog.csdn.net/yanluandai1985/article/details/88418749