标签:path 路径 http src alt htm stat web jquery
在SpringBoot项目中,静态文件应该放在哪里,有规定。
webjars:以jar包的方式引入静态资源http://www.webjars.org/
<!--引入jquery-webjar在访问的时候只需要写webjars下面资源的名称即可-->
<dependency>
<groupId>org.webjars</groupId>
<artifactId>jquery</artifactId>
<version>3.3.1</version>
</dependency>
开启8080端口
现在想访问如下.js文件,只需:localhost:8080/webjars/jquery/3.3.1/jquery.js
"classpath:/META-INF/resources/",
"classpath:/resources/",
"classpath:/static/",
"classpath:/public/"
"/":当前项目的根路径
只需将目标文件放在以上5个位置之一即可:http://localhost:8080/asserts/js/Chart.min.js
当然还可以设置首页
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> </head> <body> <h1>首页</h1> </body> </html>
标签:path 路径 http src alt htm stat web jquery
原文地址:https://www.cnblogs.com/yangyh26/p/12303086.html