mybatis自带分页如何使用
1个回答
展开全部
@RequestMapping("/login")
public String Userlogin(User user,HttpServletRequest request) {
List<User> list = userService.login(user);
if(list.isEmpty()) {
//登陆失败
request.setAttribute("error", "对不起,账号或密码输入错误");
return "forward:/login.jsp";
}else {
//登陆成功
request.getSession().setAttribute("UserLogin", list.get(0));
return "redirect:/list";
}
}
@RequestMapping("/")
public String login() {
return "redirect:/login";
}
@RequestMapping("/list")
public String list(@RequestParam(defaultValue="") String mohu,@RequestParam(defaultValue="1") int current,Model model,HttpSession session) {
User user = (User) session.getAttribute("UserLogin");
PageHelper.startPage(current, 4);
List<UserCoach> list = userService.getUserCoach(user,mohu);
PageInfo<UserCoach> page = new PageInfo<UserCoach>(list);
model.addAttribute("page", page);
model.addAttribute("mohu", mohu);
return "list";
}
public String Userlogin(User user,HttpServletRequest request) {
List<User> list = userService.login(user);
if(list.isEmpty()) {
//登陆失败
request.setAttribute("error", "对不起,账号或密码输入错误");
return "forward:/login.jsp";
}else {
//登陆成功
request.getSession().setAttribute("UserLogin", list.get(0));
return "redirect:/list";
}
}
@RequestMapping("/")
public String login() {
return "redirect:/login";
}
@RequestMapping("/list")
public String list(@RequestParam(defaultValue="") String mohu,@RequestParam(defaultValue="1") int current,Model model,HttpSession session) {
User user = (User) session.getAttribute("UserLogin");
PageHelper.startPage(current, 4);
List<UserCoach> list = userService.getUserCoach(user,mohu);
PageInfo<UserCoach> page = new PageInfo<UserCoach>(list);
model.addAttribute("page", page);
model.addAttribute("mohu", mohu);
return "list";
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询