SpringBoot引入BootStrap登陆页面

本文介绍如何在SpringBoot项目中引入Thymeleaf模板引擎和Bootstrap前端框架,实现美观的登录页面设计。文章详细展示了依赖配置、控制器映射及样式路径修改等关键步骤。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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在同一个文件夹下

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值