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;
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
ssh.zip (67个子文件)
ssh
.project 2KB
.mymetadata 282B
src
ssh
service
UserServiceImpl.java 897B
BaseService.java 286B
UserService.java 313B
CountryServiceImpl.java 678B
CountryService.java 189B
action
BaseAction.java 1KB
UserAction.java 3KB
CountryAction.java 1KB
model
User.java 664B
Country.hbm.xml 446B
User.hbm.xml 620B
Country.java 319B
dao
UserDao.java 306B
UserDaoImpl.java 1KB
CountryDao.java 133B
BaseDaoImpl.java 2KB
CountryDaoImpl.java 251B
BaseDao.java 278B
tool
Tool.java 48B
Test.java 984B
struts.xml 1KB
applicationContext.xml 4KB
hibernate.cfg.xml 1KB
WebRoot
WEB-INF
classes
ssh
service
CountryService.class 271B
UserService.class 435B
CountryServiceImpl.class 1KB
UserServiceImpl.class 1KB
BaseService.class 478B
action
BaseAction.class 2KB
UserAction.class 3KB
CountryAction.class 2KB
model
User.class 1KB
Country.hbm.xml 446B
User.hbm.xml 620B
Country.class 728B
dao
CountryDao.class 211B
BaseDaoImpl.class 3KB
UserDaoImpl.class 2KB
BaseDao.class 466B
CountryDaoImpl.class 509B
UserDao.class 423B
tool
Tool.class 255B
Test.class 2KB
struts.xml 1KB
applicationContext.xml 4KB
hibernate.cfg.xml 1KB
lib
mysql-connector-java-8.0.11.jar 1.94MB
aspectj-weaver.jar 1.55MB
jstl.jar 20KB
struts2-spring-plugin-2.5.16.jar 22KB
commons-logging-1.1.3.jar 61KB
standard.jar 384KB
web.xml 1007B
country
countrylpst.jsp 1KB
index.jsp 1KB
user
result.jsp 2KB
adduser.jsp 1KB
META-INF
MANIFEST.MF 36B
.myhibernatedata 549B
.settings
org.eclipse.wst.jsdt.ui.superType.container 49B
org.eclipse.jdt.core.prefs 330B
org.eclipse.wst.jsdt.ui.superType.name 6B
org.eclipse.core.resources.prefs 88B
.jsdtscope 500B
.classpath 1KB
共 67 条
- 1
资源评论
qq_35797490
- 粉丝: 1
- 资源: 2
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功