主要原因项目搭建的时候为了保证项目的安全,配置文件会进行访问拦截
所以引用静态资源尽管引用路径没有出错,但项目运行会找不到静态资源文件,查找不到要引用的静态资源(被系统拦截)
++++++++
解决方案:配置文件添加的代码
1 2 |
spring.mvc.static-path-pattern=/static/** spring.resources.static-locations=classpath:/static |
1 2 3 4 5 6 7 8 9 |
spring: mvc: static-path-pattern: /static/** resources: static-locations: classpath:/static thymeleaf: cache: false mode: HTML |
pom导入
1 2 3 4 |
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-thymeleaf</artifactId> </dependency> |
html引入静态资源
访问html加载js/css