首页>代码>spring mvc+mybatis+mysql最简单的入门分页数据库查询用户信息学习项目>/reg/src/com/renhe/reg/controller/UserShowAllController.java
package com.renhe.reg.controller;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import org.apache.ibatis.session.SqlSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import com.renhe.reg.util.Page;
@Controller
public class UserShowAllController {
@Autowired
SqlSession sqlSession;
@Autowired
HttpServletRequest req;
@RequestMapping("/userShowAll.action")
public String userShowAll(int num,int pageSize){
//查出用户记录总数
int count = sqlSession.selectOne("com.renhe.reg.dao.userCount");
//num:当前页号,默认为1
//pageSize:一页显示多少条记录,默认为5
Page page = new Page(pageSize, num, count);
Map<String,Object> map = new HashMap<String, Object>();
map.put("startRow", page.getStartRow());
map.put("pageSize", pageSize);
//查询得到的结果是userName---qqq,password---111,格式是map,将map放到list传回前台。
List<Map<String,Object>> datas = sqlSession.selectList("com.renhe.reg.dao.userShowAll",map);
req.setAttribute("data", datas);
req.setAttribute("page", page);
return "pages/user-showAll.jsp";
}
}
最近下载更多
李亮 LV19
2023年3月7日
liu557 LV6
2021年4月1日
andy xiao2222222 LV9
2021年3月18日
12345666 LV9
2020年7月30日
liuwenlong LV20
2019年12月21日
build138 LV20
2019年9月21日
陆信乾 LV6
2019年8月30日
ygx123321 LV4
2019年7月17日
hzhsh0223 LV18
2019年4月12日
zhangsanfengaaa LV7
2019年3月13日
最近浏览更多
微信网友_7826662819680256
2025年12月24日
暂无贡献等级
gecongkai LV8
2023年6月22日
shuidajiao
2023年6月18日
暂无贡献等级
李亮 LV19
2023年3月6日
YUProject LV8
2022年12月17日
谢谢谢谢谢谢你 LV6
2022年7月19日
陈贵明 LV2
2022年6月3日
CCG542517 LV6
2022年3月28日
494785 LV5
2021年12月15日
success1011 LV8
2021年12月15日

