package demo.action;
import org.apache.struts2.ServletActionContext;
import org.springframework.web.struts.ActionSupport;
import com.opensymphony.xwork2.ActionContext;
import demo.biz.IUserBiz;
import demo.entity.User;
public class UserAction extends ActionSupport
{
private IUserBiz userBiz;
private User user =new User();
public User getUser()
{
return user;
}
public void setUser(User user)
{
this.user = user;
}
public void setUserBiz(IUserBiz userBiz)
{
this.userBiz = userBiz;
}
public String index() throws Exception
{
ActionContext.getContext().put("userList", userBiz.get());
return "success";
}
public String add() throws Exception
{
userBiz.add(this.getUser());
return "success";
}
public String modify() throws Exception
{
userBiz.modify(this.getUser());
return "success";
}
public String delete() throws Exception
{
userBiz.delete(Integer.parseInt(ServletActionContext.getRequest().getParameter("id")));
return "success";
}
public String select() throws Exception
{
this.setUser(userBiz.get(Integer.parseInt(ServletActionContext.getRequest().getParameter("id"))));
return "success";
}
}