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; } }
最近下载更多
wanglinddad LV54
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日
sunlzh888888 LV28
2020年7月11日
最近浏览更多
sbyhm111
3月14日
暂无贡献等级
ilsfcqdf LV3
1月2日
asddwh LV12
2023年12月26日
蹇金金 LV7
2023年11月7日
shanhaijun123
2023年10月28日
暂无贡献等级
mhymhy123 LV1
2023年10月19日
微信网友_6695766784757760
2023年10月17日
暂无贡献等级
微信网友_6680567232876544 LV8
2023年10月11日
wbx666 LV1
2023年9月18日
husiyu LV3
2023年9月11日