1 Star 15 Fork 8

程序员小徐同学/SpringBoot和Thymeleaf集成基础项目

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
GPL-3.0

项目说明

本项目使用SpringBoot开发,jdbc5.1.48

1.数据库信息

创建两个表,管理员表user和员工表employee

2.项目流程

1.springboot集成thymeleaf

1).引入依赖
	<!--使用thymelaf-->
	<dependency>
	  <groupId>org.springframework.boot</groupId>
	  <artifactId>spring-boot-starter-thymeleaf</artifactId>
	</dependency>

2).配置thymeleaf模板配置
	spring:
	  thymeleaf:
	    cache: false  # 关闭缓存
	    prefix: classpath:/templates/ #指定模板位置
	    suffix: .html #指定后缀


3).开发controller跳转到thymeleaf模板
	@Controller
	@RequestMapping("hello")
	public class HelloController {

	    @RequestMapping("hello")
	    public String hello(){
	        System.out.println("hello ok");
	        return "index";  // templates/index.html
	    }
	}

================================================================= 2.thymeleaf 语法使用

1).html使用thymeleaf语法 必须导入thymeleaf的头才能使用相关语法
	namespace: 命名空间  
	<html lang="en" xmlns:th="http://www.thymeleaf.org">


2).在html中通过thymeleaf语法获取数据

================================================================

###3.案例开发流程

​ ​

需求分析: 分析这个项目含有哪些功能模块
	用户模块:
		注册
		登录
		验证码
		安全退出
		真是用户
	员工模块:
		添加员工+上传头像
		展示员工列表+展示员工头像
		删除员工信息+删除员工头像
		更新员工信息+更新员工头像

库表设计(概要设计): 1.分析系统有哪些表  2.分析表与表关系  3.确定表中字段(显性字段 隐性字段(业务字段))

	2张表 
		1.用户表 user
			id username realname password gender

		2.员工表 employee
			id name salary birthday  photo

	创建一个库: ems-thymeleaf

详细设计:
	省略

编码(环境搭建+业务代码开发)
	1.创建一个springboot项目 项目名字: ems-thymeleaf
	2.修改配置文件为 application.yml  pom.xml  2.5.0
	3.修改端口   项目名: ems-thymeleaf
	4.springboot整合thymeleaf使用
		a.引入依赖
		b.配置文件中指定thymeleaf相关配置
		c.编写控制器测试

	5.springboot整合mybatis
		a.引入依赖
			mysql、druid、mybatis-springboot-stater

		b.配置文件中 

	6.导入项目页面
		static  存放静态资源

		templates 目录 存放模板文件



测试
上线部署
维护
发版

完整项目说明

空文件

简介

本项目使用SpringBoot开发,jdbc5.1.48,mybatis 其中涉及功能有:Mybatis的使用,Thymeleaf的使用,验证码的设计,图片的文件上传(本文件上传到本地,没有传到数据库)登录过滤等 基本的增删改查都有 展开 收起
README
GPL-3.0
取消

发行版

暂无发行版

贡献者

全部

近期动态

不能加载更多了
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Java
1
https://gitee.com/crazy-xu-dada/SpringBootStudy.git
git@gitee.com:crazy-xu-dada/SpringBootStudy.git
crazy-xu-dada
SpringBootStudy
SpringBoot和Thymeleaf集成基础项目
master

搜索帮助