1.pom依赖:
即:spring-boot的基本jar ---- 内置springmvc和spring
Thymeleaf jar
热部署 jar ---方便二次加载 ctrl+f9再次编译
Mybatis jar
Mysql jar <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency> <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency> <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</dependency> <!--热部署-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional> <!-- 这个需要为 true 热部署才有效 -->
</dependency>
<!-- mybatis -->
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>1.1.1</version>
</dependency>
<!-- mysql -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.21</version>
</dependency> 2.application的配置:
#thymeleaf 配置
spring.thymeleaf.mode=HTML5
spring.thymeleaf.encoding=UTF-8
spring.thymeleaf.content-type=text/html
#缓存设置为false, 这样修改之后马上生效,便于调试
spring.thymeleaf.cache=false
#上下文
server.context-path=/thymeleaf
#视图层控制
#spring.mvc.view.prefix=classpath:/templates/
#spring.mvc.view.suffix=.html
#spring.mvc.static-path-pattern=/static/**
#数据库
spring.datasource.url=jdbc:mysql://127.0.0.1:3306/how2java?characterEncoding=UTF-8
spring.datasource.username=root
spring.datasource.password=
spring.datasource.driver-class-name=com.mysql.jdbc.Driver 3.mapper层 以及非常简单的entity层:
@Mapper
@Repository
// 加上Repository注解,即可自动bean
public interface CategoryMapper { @Select("select * from category_ ")
public List<Category> findAll(); } 4.service层 --- 以及serviceImpl实现层
@Service
public class CategoryServiceImpl implements CategoryService {
@Autowired
CategoryMapper; @Override
public List<Category> selectAll() {
return categoryMapper.findAll();
}
}
5.controller层:
这个里面加了pagehelper,可以忽略
@Controller
public class CategoryController {
@Autowired
CategoryService categoryService; @RequestMapping("/listCategory")
public String showList(Model model,
@RequestParam(value = "start", defaultValue = "0") int start,
@RequestParam(value = "size", defaultValue = "5") int size)
throws Exception{
PageHelper.startPage(start,size);
List<Category> list = categoryService.selectAll();
PageInfo<Category> page = new PageInfo<>(list);
model.addAttribute("page",page);
return "listCategory";
}
} 6.Thymeleaf --- 渲染模板: 有点类似于EL表达式的写法
<table border="1px">
<tr>
<th>id</th>
<th>name</th>
</tr>
<tr th:each="l:${page.list}">
<td th:text="${l.id}"></td>
<td th:text="${l.name}"></td>
</tr>
</table>
<a th:href="@{/listCategory(start=0)}">[首 页]</a>
<a th:href="@{/listCategory(start=${page.pageNum-1})}">[上一页]</a>
<a th:href="@{/listCategory(start=${page.pageNum+1})}">[下一页]</a>
<a th:href="@{/listCategory(start=${page.pages})}">[末 页]</a>

  

springboot --- 之SSM框架整合的更多相关文章

  1. SpringMVC详解及SSM框架整合项目

    SpringMVC ssm : mybatis + Spring + SpringMVC MVC三层架构 JavaSE:认真学习,老师带,入门快 JavaWeb:认真学习,老师带,入门快 SSM框架: ...

  2. SSM框架整合项目 :租房管理系统

    使用ssm框架整合,oracle数据库 框架: Spring SpringMVC MyBatis 导包: 1, spring 2, MyBatis 3, mybatis-spring 4, fastj ...

  3. 基于maven的ssm框架整合

    基于maven的ssm框架整合 第一步:通过maven建立一个web项目.                第二步:pom文件导入jar包                              (1 ...

  4. JavaWeb之ssm框架整合,用户角色权限管理

    SSM框架整合 Spring SpringMVC MyBatis 导包: 1, spring 2, MyBatis 3, mybatis-spring 4, fastjson 5, aspectwea ...

  5. SSM框架整合环境构建——基于Spring4和Mybatis3

    目录 环境 配置说明 所需jar包 配置db.properties 配置log4j.properties 配置spring.xml 配置mybatis-spring.xml 配置springmvc.x ...

  6. Springboot,SSM框架比较,区别

    百度搜 Springboot,SSM框架区别,大多说的都是 1.springboot一个应用是一个可执行jar 2.将原有的xml配置,简化为java配置 他们说的确实没错,可是根本没有说到本质,百度 ...

  7. 基于springboot的SSM框架实现返回easyui-tree所需要数据

    1.easyui-tree easui-tree目所需要的数据结构类型如下: [ { "children": [ { "children": [], " ...

  8. springmvc(二) ssm框架整合的各种配置

    ssm:springmvc.spring.mybatis这三个框架的整合,有耐心一步步走. --WH 一.SSM框架整合 1.1.整合思路 从底层整合起,也就是先整合mybatis与spring,然后 ...

  9. SSM框架整合的其它方式

    ---------------------siwuxie095                                 SSM 框架整合的其它方式         1.主要是整合 Spring ...

随机推荐

  1. ca76a_c++_流文件打开输入输出文件模式p773

    /*ca76a_c++_流文件打开输入输出文件模式利用文件流打开文件进行输入与输出时的选项in.out.app(附加模式).ate((end)文件打开后,定于文件结尾).trunc(裁剪).binar ...

  2. 有趣的程序分析之C

    1. 下面的函数被用来计算某个整数的平方,它能实现预期设计目标吗?如果不能,试回答存在什么问题: 1 2 3 4 int square( volatile int *ptr ) {     retur ...

  3. django 网站域名解析 IP绑定 新建站 新域名

    备案成功后,我们要用域名来访问服务器,这个不仅要修改nginx的配置文件,还要设置域名的解析,下面是我的一个调试经验过程:直接上图了. 1.问题查找

  4. java中值传递

    最近学基础的时候,老师讲了值传递和引用传递,这个问题一直不太明白,上网查了很多资料,按照自己的理解整理了一遍,发现之前不太明白的地方基本上想明白了,如有不正确的地方,欢迎指正,谢谢. 首先要说明的是j ...

  5. 跟着whatwg看一遍事件循环

    前言 对于单线程来说,事件循环可以说是重中之重了,它为任务分配不同的优先级,井然有序的调度.让js解析,用户交互,页面渲染等互不冲突,各司其职. 我们书写的代码无时无刻都在和事件循环打交道,要想写出更 ...

  6. Jenkins入门-环境搭建(1)-转

    因为Jenkins的环境搭建比较简单,本来不想来介绍,但是发现有些入门小朋友,从各种网站上下载的各种安装包来搭建,最后导致出现了各种千奇百怪的问题,介于这种情况下我决定还是来写一下Jenkins的环境 ...

  7. docx.opc.exceptions.PackageNotFoundError: Package not found at '文件名.docx' 问题解决

    编译源程序时,提示:docx.opc.exceptions.PackageNotFoundError: Package not found at '文件名.docx' . 源文件明明存在啊,难道是用的 ...

  8. Apache Dubbo Provider默认反序列漏洞复现(CVE-2020-1948)

    Apache Dubbo Provider默认反序列漏洞(CVE-2020-1948) 0x01 搭建漏洞环境 漏洞介绍 2020年06月23日, 360CERT监测发现Apache Dubbo 官方 ...

  9. 【WPF】DataGrid多表头的样式设计

    需求 在使用WPF开发时,使用DataGrid列表显示数据时,有些字段可以进行分组显示,用于更好的表达它们之间存在的某种关系,因此就考虑到要对DataGrid的表头进行扩展,可以显示多行表头,让这些有 ...

  10. 如何理解nginx反向代理,其实叫逆向代理更容易让我理解

    接触nginx后,以我的语文水平,一直无法理解它神奇的名字:反向代理 怎么就反向了?反哪里去了 (以下部分图片.内容来自网络整理) 1.先理解正向代理 正向代理( Forward Proxy ): 客 ...