package com.action; import java.util.List; import java.util.Map; import org.apache.struts2.ServletActionContext; import com.dao.TAdminDAO; import com.model.TAdmin; import com.opensymphony.xwork2.ActionSupport; import com.util.Pagination; public class adminAction extends ActionSupport { private int userId; private String userName; private String userPw; private String message; private String path; private int index=1; private TAdminDAO adminDAO; public String adminAdd() { TAdmin admin=new TAdmin(); admin.setUserName(userName); admin.setUserPw(userPw); adminDAO.save(admin); this.setMessage("操作成功"); this.setPath("adminManage.action"); return "succeed"; } public String adminManage() { List adminList=adminDAO.findAll(); Map request=(Map)ServletActionContext.getContext().get("request"); request.put("adminList", adminList); return ActionSupport.SUCCESS; } public String adminManageFenye() { List adminList=adminDAO.findAll(); int pageSize=3; int fromIndex = (index - 1) * pageSize; int toIndex = Math.min(fromIndex + pageSize, adminList.size()); List adminListFenye = adminList.subList(fromIndex, toIndex); Pagination p = new Pagination();//创建 分页对象 p.setIndex(index);//设置页数 p.setPageSize(pageSize); p.setTotle(adminList.size());//设置总共的条数 p.setData(adminListFenye);//设置数据 p.setPath("adminManageFenye.action?");//跳转的路径 Map request=(Map)ServletActionContext.getContext().get("request"); request.put("page", p); return ActionSupport.SUCCESS; } public String adminDel() { adminDAO.delete(adminDAO.findById(userId)); this.setMessage("删除成功"); this.setPath("adminManage.action"); return "succeed"; } public TAdminDAO getAdminDAO() { return adminDAO; } public void setAdminDAO(TAdminDAO adminDAO) { this.adminDAO = adminDAO; } public String getMessage() { return message; } public int getIndex() { return index; } public void setIndex(int index) { this.index = index; } public void setMessage(String message) { this.message = message; } public String getPath() { return path; } public void setPath(String path) { this.path = path; } public int getUserId() { return userId; } public void setUserId(int userId) { this.userId = userId; } public String getUserName() { return userName; } public void setUserName(String userName) { this.userName = userName; } public String getUserPw() { return userPw; } public void setUserPw(String userPw) { this.userPw = userPw; } }

angaochong LV5
2024年10月21日
wanglinddad LV55
2022年4月1日
ericxu1116 LV24
2021年6月16日
995591560 LV3
2021年6月6日
皓腕凝霜雪 LV2
2021年5月9日
YiRenHun LV11
2021年4月11日
浴皇大帝 LV8
2021年3月22日
jinandfei LV12
2021年3月17日
clwy0617 LV2
2021年2月11日
835512308 LV14
2020年12月20日