1.引入thymeleaf和webjars中的bootstrap
<dependency>
<groupId>org.webjars</groupId>
<artifactId>bootstrap</artifactId>
<version>4.3.1</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
2.BootStrap提供的登陆页面
效果
3.引入SpringBoot项目
4.首页映射
@Controller
public class indexController {
@RequestMapping("/")
public String index(){
return "index";
}
}
5.修改index.html中引入样式的路径
<!--引入webjars中的bootstrap的css -->
<link th:href="@{/webjars/bootstrap/4.3.1/css/bootstrap.css}" rel="stylesheet">
<!--引用bootstrap官方登陆页面的css -->
<link th:href="@{/css/signin.css}" rel="stylesheet">
需要注意的是,SpringBoot编译后static和templates在同一个文件夹下