springboot中的html引入js、css文件
程序员文章站
2022-07-10 17:43:25
...
在Spring Boot项目中,默认配置的/**映射到/static,一般src/main/resources/static目录用于存放各类静态资源文件,例如css、js和image等。src/main/resources/templates用于存放页面文件,例如html,jsp等。
目录结构如下:
application.yml配置如下:
server:
port: 8080
spring:
thymeleaf:
#这个是配置html资源目录,如果直接放在templates下不用配置
#prefix: classpath:/templates/view/
cache: false
html中引入js、css:
<link rel="stylesheet" type="text/css" href="css/normalize.css" />
<link rel="stylesheet" type="text/css" href="css/default.css">
<script src='js/prefixfree.min.js'></script>
<link rel="stylesheet" type="text/css" href="css/styles.css">
controller代码如下:
@Controller
public class LoginController {
@RequestMapping("login")
public String login(){
return "index";
}
}
上一篇: netopeer-cli手册翻译
下一篇: vue+ElementUI首个实例
推荐阅读
-
vue.js引入外部CSS样式和外部JS文件的方法
-
使用PDF.JS插件在HTML中预览PDF文件的方法
-
nodejs遍历文件夹下并操作HTML/CSS/JS/PNG/JPG的方法
-
Asp.net合并JS,Css文件,只要在路径中添加要压缩的文件名
-
springboot中jsp引用静态资源css,js的实现方法
-
ASP.NET2.0:页面中链入的CSS、js文件带中文时需注意
-
用python给html里的css及js文件链接自动添加版本号
-
为什么要在引入的css或者js文件后面加参数的详细讲解
-
如何使用php脚本给html中引用的js和css路径打上版本号
-
将一个html文件引入另一个html文件的div中