博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Mybatis——SSM
阅读量:7055 次
发布时间:2019-06-28

本文共 4029 字,大约阅读时间需要 13 分钟。

目录结构

1、相关依赖

org.springframework
spring
2.5.6
org.springframework
spring-context
5.0.2.RELEASE
org.springframework
spring-core
4.3.16.RELEASE
org.springframework
spring-beans
4.3.14.RELEASE
org.springframework
spring-jdbc
4.3.16.RELEASE
org.springframework
spring-orm
4.3.16.RELEASE
org.springframework
spring-web
4.3.16.RELEASE
org.springframework
spring-webmvc
4.3.16.RELEASE
org.springframework
spring-aop
4.3.16.RELEASE
commons-logging
commons-logging
1.2
jstl
jstl
1.2
mysql
mysql-connector-java
6.0.6
org.mybatis
mybatis
3.4.5
org.mybatis
mybatis-spring
1.3.1
junit
junit
4.11
test

2、配置mybatis配置文件

mybatis-config.xml、mapper.xml、dbConfig.properties

3、配置spring配置文件

在web.xml中做出spring的配置

contextConfigLocation
classpath:applicationContext.xml

并新建spring配置文件

在web.xml中配置前端控制器

spring
org.springframework.web.servlet.DispatcherServlet
spring
/
在WEB-INFO下创建spring-servlet.xml

在其中配置上

配置applicationContext.xml

编辑controller层和service层以及页面

@Servicepublic class EmployeeService {    @Autowired    private EmployeeMapper mapper;    public List
getEmps(){ return mapper.getEmps(); }}

@Controllerpublic class EmployeeController {    @Autowired    EmployeeService employeeService;    @RequestMapping(value = "/getEmps")    public String emps(Map
map){ List
emps = employeeService.getEmps(); map.put("allEmps",emps); return "list"; }}
<%@ page language="java" contentType="text/html; charset=UTF-8"         pageEncoding="UTF-8"%><%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>    员工列表    
id lastName email gender
#{
emp.id}
#{
emp.lastName}
#{
emp.email}
#{
emp.gender}

Hello World!

查询所有员工

转载于:https://www.cnblogs.com/huangzhe1515023110/p/9276080.html

你可能感兴趣的文章
session的两个小案例
查看>>
致互联网--那些我浅尝则止的昙花
查看>>
李洪强漫谈iOS开发[C语言]-045-循环结构
查看>>
验证码识别
查看>>
国内maven 仓库
查看>>
Capture and report JavaScript errors with window.onerror
查看>>
Git系列二之数据管理
查看>>
JNI/NDK开发指南(九)——JNI调用性能測试及优化
查看>>
scrapy-splash抓取动态数据例子十四
查看>>
php中奖概率算法,可用于刮刮卡,大转盘等抽奖算法
查看>>
go 学习资源和GitHub库
查看>>
如何用路由器改成WiFi Pineapple系统镜像网络流量
查看>>
Zabbix触发器函数(取前后差值)
查看>>
Postman
查看>>
STS开发环境搭建与配置
查看>>
moment.js aka underscore.date.js
查看>>
精悍的Python代码段
查看>>
XCode数据类型转换代码 文件读取,写入,XY坐标获取,ASCII转换等
查看>>
定制默认系统帐号不能被更新与删除
查看>>
Ado.Net Entity Framework的使用
查看>>