首页>代码>S2SH(spring+struts2+hibernate)整合开发java web人事后台管理系统>/sshDemo/src/com/wgc/action/UserAction.java
package com.wgc.action; import java.util.List; import com.opensymphony.xwork2.ActionContext; import com.wgc.entity.User; import com.wgc.util.HrmConstants; /** * 处理User操作的Action * */ public class UserAction extends AbstractAction { private User user; private String message; private List<User> lists; public User getUser() { return user; } public void setUser(User user) { this.user = user; } public String getMessage() { return message; } public void setMessage(String message) { this.message = message; } public List<User> getLists() { return lists; } public void setLists(List<User> lists) { this.lists = lists; } /** * 登录功能 * */ public String login() throws Exception { user = sshService.login(user.getLoginname(), user.getPassword()); if(user != null){ // 保存到HttpSession ActionContext.getContext().getSession() .put(HrmConstants.USER_SESSION,user); return SUCCESS; }else{ this.message = "登录名或密码错误!请重新登录!"; return HrmConstants.LOGIN; } } /** * 每一个查询页面都做了分页,分页的功能封装到PageModel当中 * * */ public String selectUser() throws Exception { System.out.println("selectUser() -->"); // 设置请求页数 if(this.pageIndex != null){ this.pageModel.setPageIndex(pageIndex); } // 查询总数 Integer recordCount = sshService.getUserCount(); // 把用户总数设置到pageModel当中 this.pageModel.setRecordCount(recordCount); // 查询数据 this.lists = sshService.selectPage(this.pageModel); return SUCCESS; } //查询 public String selectUserByComtition() throws Exception { System.out.println("selectUserByComtition() -->"); // 设置请求页数 if(this.pageIndex != null){ this.pageModel.setPageIndex(pageIndex); } // 查询总数 Integer recordCount = sshService.getUserCountByComdition(user.getUsername(), user.getStatus()); // 把用户总数设置到pageModel当中 this.pageModel.setRecordCount(recordCount); // 查询数据 this.lists = sshService.selectUserByComdition(pageModel, user.getUsername(), user.getStatus()); return SUCCESS; } //通过用户名或者用户状态查询 public String selectUserByNameOrStutas() throws Exception { System.out.println("selectUserByNameOrStutas() -->"); return SUCCESS; } public String removeUser() throws Exception { System.out.println("removeUser() -->"); /** * ids传过来是字符串>>"1,2,3,4" * 通过split分割再存进数组》》》》id[0]=1 id[1]=2 id[2]=3 */ String[] temp = ids.split(","); System.out.println("temp>>>>"+temp); for(String id:temp) { sshService.removeUser(Integer.parseInt(id)); } return SUCCESS; } /** * 1 跳转带添加页面 * 2 提交到数据库 */ public String addUser() throws Exception { if(flag.equals("1")) { return "showAddUser"; } else { sshService.saveUser(user); return SUCCESS; } } /** * 1 跳转带修改页面 * 2 提交到数据库 */ public String updateUser() throws Exception { if(flag.equals("1")) { user = sshService.findUserId(id); return "showUpdateUser"; } else { sshService.updateUser(user); return SUCCESS; } } }

程健飞 LV2
2023年3月30日
Hugo_0901 LV5
2022年4月27日
wanglinddad LV55
2022年4月19日
wangzile1994 LV12
2022年4月16日
槛外人 LV6
2022年3月29日
afei115 LV4
2021年11月29日
864152530 LV5
2021年6月7日
zuihaofdfdfdfdddd LV10
2021年5月30日
1207748096 LV6
2021年5月12日
and123456 LV11
2021年4月20日

黄志琴 LV1
前天
微信网友_7407113009926144 LV1
3月3日
charies778
1月7日
暂无贡献等级
AOAO1234 LV2
2024年12月23日
asfsghjhgsfadaas
2024年12月16日
暂无贡献等级
isssssss7
2024年10月13日
暂无贡献等级
lqzixi LV4
2024年10月9日
WBelong LV8
2023年12月15日
zhangyanghao
2023年9月21日
暂无贡献等级
lcqlcl LV11
2023年8月29日