package ssh.action;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import org.apache.struts2.ServletActionContext;
import com.opensymphony.xwork2.ActionSupport;
import ssh.model.User;
import ssh.service.UserService;
public class UserAction extends ActionSupport {
private static final long serialVersionUID = 5047953792466141013L;
private UserService userService;
public UserService getUserService() {
return userService;
}
public void setUserService(UserService userService) {
this.userService = userService;
}
public String getAllUser() {
HttpServletRequest request = ServletActionContext.getRequest();
List<User> userlist = userService.getAllUser();
request.setAttribute("userlist", userlist);
return SUCCESS;
}
public String addUser() {
HttpServletRequest request = ServletActionContext.getRequest();
User user = new User();
user.setUsername(request.getParameter("username"));
user.setPassword(request.getParameter("password"));
user.setNickname(request.getParameter("nickname"));
userService.addUser(user);
return SUCCESS;
}
public String deleteUser() {
HttpServletRequest request = ServletActionContext.getRequest();
String id = request.getParameter("uid");
userService.deleteUser(Integer.parseInt(id));
return SUCCESS;
}
public String updateUser() {
HttpServletRequest request = ServletActionContext.getRequest();
User user = new User();
user.setId(Integer.parseInt(request.getParameter("uid")));
user.setUsername(request.getParameter("username"));
user.setPassword(request.getParameter("password"));
user.setNickname(request.getParameter("nickname"));
userService.updateUser(user);
return SUCCESS;
}
public String getUserByConditions() {
HttpServletRequest request = ServletActionContext.getRequest();
Map<String, String> query = new HashMap<String, String>();
User user = new User();
String id = request.getParameter("uid");
if(id != null && !id.equals("")) {
user.setId(Integer.parseInt(id));
query.put("uid", id);
}
String username = request.getParameter("username");
if(username != null && !username.equals("")) {
user.setUsername(username);
query.put("username", username);
}
String password = request.getParameter("password");
if(password != null && !password.equals("")) {
user.setPassword(password);
query.put("password", password);
}
String nickname = request.getParameter("nickname");
if(nickname != null && !nickname.equals("")) {
user.setNickname(nickname);
query.put("nickname", nickname);
}
List<User> userlist = userService.getUserByConditions(user);
request.setAttribute("userlist", userlist);
request.setAttribute("query", query);
return SUCCESS;
}
}
qq_35797490
- 粉丝: 1
- 资源: 2
最新资源
- 毕业设计-基于java的校园二手交易系统毕业设计-全部资料+详细文档+高分项目+源码.zip
- 毕业设计-基于java电影院订票选座系统,带论文全部资料+详细文档+高分项目+源码.zip
- 毕业设计-基于JSP+Servlet的网上书店系统全部资料+详细文档+高分项目+源码.zip
- 毕业设计-基于Node.js,Angular,Express,ESP8266 WIFI芯片的物联网温度采集系统-全部资料+详细文档+高分项目+源码.zip
- S7-200SMART V2.8版本 PID自整定快速入门指南.rar
- 毕业设计-基于SpringBoot的二手商城系统二手交易平台,校园二手书籍交易,社区二手交易平台全部资料+详细文档+高分项目+源码.zip
- 毕业设计-基于SSH框架的外卖点餐系统全部资料+详细文档+高分项目+源码.zip
- 毕业设计-基于SpringBoot及thymeleaf搭建的疫情信息管理系统全部资料+详细文档+高分项目+源码.zip
- 毕业设计-基于SSM的毕业设计-论文题目审核及选题管理系统全部资料+详细文档+高分项目+源码.zip
- 毕业设计-基于SSM+AmazeUI培训中心管理系统全部资料+详细文档+高分项目+源码.zip
- 毕业设计-基于SSM城市公交查询系统全部资料+详细文档+高分项目+源码.zip
- 毕业设计-基于SSM的人力资源管理系统-全部资料+详细文档+高分项目+源码.zip
- 毕业设计-基于SSM电影院订票系统全部资料+详细文档+高分项目+源码.zip
- 毕业设计-基于SSM技术的宿舍管理系统全部资料+详细文档+高分项目+源码.zip
- 毕业设计-基于SSM精品课程在线学习系统全部资料+详细文档+高分项目+源码.zip
- 毕业设计-基于SSM教务选课成绩管理系统全部资料+详细文档+高分项目+源码.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈