SpringBoot 2.0 学习(四)之thymeleaf模板
更多Spring Boot 2.0学习内容,请参考我的CSDN博客Spring Boot 2.0学习笔记
学习一门新的技术,起码的CURD增删改查是必要的,所以自己也简单的用thymeleaf模板完成了增删改查的操作
SpringBoot+thymeleaf+JdbcTemplate增删改查
第一步:在pom.xml里面添加相关依赖
<!-- Spring JDBC 的依赖包,使用 spring-boot-starter-jdbc 将会自动获得HikariCP依赖 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<!-- MYSQL依赖包 -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<!-- 阿里巴巴druid数据源 -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
<version>1.1.12</version>
</dependency>
第二步:依次编写实体domain(此处省略)、Dao、Service、实现类、Controller类的编写








第三步:使用thymeleaf在src/main/resources/templates目录下listUser.html和saveOrUpdate.html


第四步:运行项目,浏览器输入http://localhost:9090/user/showAllUser,如下即表示访问ok



如果前端页面代码发生更改,不想反复重启服务器,怎么办?
application.properties里面添加spring.thymeleaf.cache=false