struts2的action衔接JSP和DAO
Posted XuGuobao
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了struts2的action衔接JSP和DAO相关的知识,希望对你有一定的参考价值。
1 import org.lxh.mvcdemo.factory.DAOFactory; 2 import org.lxh.mvcdemo.vo.User; 3 4 import com.opensymphony.xwork2.ActionContext; 5 import com.opensymphony.xwork2.ActionSupport; 6 7 public class MVCAction extends ActionSupport{ 8 private String user_id; 9 private String user_pass; 10 11 public String getUser_id() { 12 return user_id; 13 } 14 15 public void setUser_id(String userId) { 16 user_id = userId; 17 } 18 19 public String getUser_pass() { 20 return user_pass; 21 } 22 23 public void setUser_pass(String userPass) { 24 user_pass = userPass; 25 } 26 27 public String execute()throws Exception{ 28 User user = new User(); 29 //ActionContext.getContext().getSession().put("user_id", user_id); 30 //ActionContext.getContext().getSession().put("user_pass", user_pass); 31 32 user.setUserid(getUser_id()); 33 user.setPassword(getUser_pass()); 34 35 if(DAOFactory.getIUserDAOInstance().findLogin(user)){ 36 return "success"; 37 }else{ 38 return "error"; 39 } 40 } 41 }
以上是关于struts2的action衔接JSP和DAO的主要内容,如果未能解决你的问题,请参考以下文章