/**
* DataGrid对象
*
*/
@SuppressWarnings("rawtypes")
public class DataGrid {
private int total = 0;
private List rows = new ArrayList();
public int getTotal() {
return total;//数据总数
}
public void setTotal(int total) {
this.total = total;
}
public List getRows() {
return rows;//页面显示的数据
}
public void setRows(List rows) {
this.rows = rows;
}
}

  

public class UserInfoDO {
private String userName;// 用户姓名
private String phoneNum;//用户电话
private String identityNum;//卡号
private String plStatus;//插件状态
private int startNum;//分页-起始数
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getPhoneNum() {
return phoneNum;
}
public void setPhoneNum(String phoneNum) {
this.phoneNum = phoneNum;
}
public String getIdentityNum() {
return identityNum;
}
public void setIdentityNum(String identityNum) {
this.identityNum = identityNum;
}
public String getPlStatus() {
return plStatus;
}
public void setPlStatus(String plStatus) {
this.plStatus = plStatus;
}
public int getStartNum() {
return startNum;
}
public void setStartNum(int startNum) {
this.startNum = startNum;
}
}

  

public class UserInfoController {
@Autowired
private UserInfoService userInfoService;
/**
* 查询
*
* @return
*/
@RequestMapping(value = "/userInfo.do", method = RequestMethod.POST)
@ResponseBody
public String getList(@RequestBody UserInfoDO userInfoDo, HttpServletRequest request, HttpServletResponse response) {
JSONObject jsonObject = new JSONObject();
try {
DataGrid dataGrid = userInfoService.getUserInfo(userInfoDo);
jsonObject = JSONObject.fromObject(dataGrid);
} catch (Exception e) {
e.printStackTrace();
}
return jsonObject.toString();
}
}

  

public interface UserInfoService {
public DataGrid getUserInfo(UserInfoDO userInfoDo) throws SQLException;
}

  

@Service
public class SignLogServiceImpl implements SignLogService {
@Resource
private SignLogDao signLogDao;
@Override
public DataGrid getSignLog(SignLogDO signLogDo) throws SQLException {
DataGrid grid = new DataGrid();
List<SignLogDO> signLogList = null;
try {
signLogList = signLogDao.getSignLog(signLogDo);
grid.setTotal(signLogDao.getTotalNum(signLogDo));
grid.setRows(signLogList);
}
catch (Exception e) {
e.printStackTrace();
}
return grid;
}
}

  

public interface UserInfoDao {

	public List<UserInfoDO> getUserInfo(UserInfoDO userInfoDo) throws SQLException;

	public int getTotalNum(UserInfoDO userInfoDo) throws SQLException;

}

  

@Repository
public class UserInfoDaoImpl extends SqlSessionDaoSupport implements UserInfoDao{
@Resource
public void setSqlSessionFactory(SqlSessionFactory sqlSessionFactory){
super.setSqlSessionFactory(sqlSessionFactory);
}
@Override
public List<UserInfoDO> getUserInfo(UserInfoDO userInfoDo) throws SQLException {
return this.getSqlSession().selectList("userInfoDO.getUserInfo",userInfoDo);
}
@Override
public int getTotalNum(UserInfoDO userInfoDo) throws SQLException {
return this.getSqlSession().selectOne("userInfoDO.getTotalNum",userInfoDo);
}
}

  

<mapper namespace="userInfoDO">
<resultMap id="BaseResultMap" type="UserInfoDO">
<result column="phone_num" property="phoneNum" jdbcType="VARCHAR"/>
<result column="user_name" property="userName" jdbcType="VARCHAR"/>
<result column="identity_num" property="identityNum" jdbcType="VARCHAR"/>
</resultMap> <select id="getUserInfo" resultMap="BaseResultMap" parameterType="UserInfoDO">
select phone_num,user_name,identity_num from tb_user
<where>
<if test="phoneNum!=null and phoneNum!=''">
phone_num like '%${phoneNum}%'
</if>
<if test="userName != '' and userName != null" >
and user_name like '%${userName}%'
</if>
<if test="identityNum != '' and identityNum != null" >
and identity_num like '%${identityNum}%'
</if>
</where>
limit #{startNum},5 //每页五条数据
</select> <select id="getTotalNum" resultType="int" parameterType="UserInfoDO">
select count(*) from tb_user
<where>
<if test="phoneNum!=null and phoneNum!=''">
phone_num like '%${phoneNum}%'
</if>
<if test="userName != '' and userName != null" >
and user_name like '%${userName}%'
</if>
<if test="identityNum != '' and identityNum != null" >
and identity_num like '%${identityNum}%'
</if>
</where>
</select>
</mapper>

  

ssm框架查询数据并实现分页功能示例的更多相关文章

  1. ASP.NET Core 使用 EF 框架查询数据 - ASP.NET Core 基础教程 - 简单教程,简单编程

    原文:ASP.NET Core 使用 EF 框架查询数据 - ASP.NET Core 基础教程 - 简单教程,简单编程 ASP.NET Core 使用 EF 框架查询数据 上一章节我们学习了如何设置 ...

  2. SSM框架搭建web服务器实现登录功能(Spring+SpringMVC+Mybatis)

    初学java EE,虽然知道使用框架会使开发更加便捷高效,但是对于初学者来说,感到使用框架比较迷惑,尤其是各种jar包的引用.各种框架的配置.注解的使用等等. 最好的学习方法就是实践,于是下载了一个现 ...

  3. python连接 elasticsearch 查询数据,支持分页

    使用python连接es并执行最基本的查询 from elasticsearch import Elasticsearch es = Elasticsearch(["localhost:92 ...

  4. php基于SQLite实现的分页功能示例

    php基于SQLite实现的分页功能. 这里操作数据库文件使用的是前面文章<PHP基于PDO实现的SQLite操作类>中的SQLite数据库操作类. 代码: <?php class ...

  5. SSM框架三分钟搞定分页查询

    使用的国产第三方jar   pagehelper 里面的基本属性值 //当前页 private int pageNum; //每页的数量 private int pageSize; //当前页的数量 ...

  6. java 工作流项目源码 SSM 框架 Activiti-master springmvc 有手机端功能

    即时通讯:支持好友,群组,发图片.文件,消息声音提醒,离线消息,保留聊天记录 (即时聊天功能支持手机端,详情下面有截图) 工作流模块---------------------------------- ...

  7. SPA项目开发动态树、数据表格、分页功能

    SPA项目开发 1.修改左侧动态树 LeftNav.vue <template> <el-menu router :" class="el-menu-vertic ...

  8. (菜鸟要飞系列)五,基于Asp.Net MVC5的后台管理系统(添加数据表的分页功能)

    献上代码 ) { List<UserModel> arrayUserModel = new List<UserModel>(); string strText = Reques ...

  9. SSM框架手动实现分页逻辑(非PageHelper)

    第一种方法:查询出所有数据再分页 分析: 分页时,需要获得前台传来的两个参数,分别为pageNo(第几页数据),pageSize(每页的条数); 根据这两个参数来计算出前端需要的数据是查出数据list ...

随机推荐

  1. busybox filesystem ifup

    /******************************************************************** * busybox filesystem ifup * 声明 ...

  2. DataGuard相同SID物理Standby搭建

    Oracle Data Guard 是针对企业数据库的最有效和最全面的数据可用性.数据保护和灾难恢复解决方案.它提供管理.监视和自动化软件基础架构来创建和维护一个或多个同步备用数据库,从而保护数据不受 ...

  3. oracle归档日志增长过快处理方法

    oracle归档日志一般由dml语句产生,所以增加太快应该是dml太频繁 首先查询以下每天的归档产生的情况: SELECT TRUNC(FIRST_TIME) "TIME", SU ...

  4. 【转】【玩转cocos2d-x之二十三】多线程和同步03-图片异步加载

    原创作品,转载请标明:http://blog.csdn.net/jackystudio/article/details/15334159 cocos2d-x中和Android,Windows都 一样, ...

  5. date.plugin.js 日期插件

    //定义命名空间 var DatePlugin; if (!DatePlugin) DatePlugin = {}; /*整理时间:2015-05-28*/ var defaultFormat = & ...

  6. C++ Primer学习_第1章

    源文件后缀 在大多数的系统中,源文件的名字以一个后缀为结尾,后缀是由一个句点后接一个或多个字符组成的.后缀告诉系统这个文件是一个C++程序.不同编译器使用不同的后缀命名约定,最常见的包括.cc..cx ...

  7. IOS 疑问记录

    1. NSThread  中的  NSRunLoop 2. NSThread  中的 performSelector:onThread:withObject:waitUntilDone:

  8. qt集成到vs2010

    因为要正式开始学习图形处理相关的知识了,所以要搭建开发平台.我所要用到的平台主要是vs和qt.虽然现在已经出了vs2013了,并且外观看起来特别漂亮,但是我所要用到的qt4版本中,没有对于的qtAdd ...

  9. 重新安装Photoshop CS6以后启动软件出现Licensing for this product has expired

    当我们卸载试用版本Photoshop CS6并且重新安装,出现Licensing for this product has expired,并且无法打开软件,这是由于证书过期导致的,解决办法是将计算机 ...

  10. Core Java 学习笔记——1.术语/环境配置/Eclipse汉化字体快捷键/API文档

    今天起开始学习Java,学习用书为Core Java.之前有过C的经验.准备把自己学习这一本书时的各种想法,不易理解的,重要的都记录下来.希望以后回顾起来能温故知新吧.也希望自己能够坚持把自己学习这本 ...