查询不起作用struts2

时间:2016-06-02 09:14:11

标签: struts2

它适用于struts2,但数据不会在数据库中更新,它将重新生成原始数据.ddatabase连接正确,只显示公共字符串update()方法中的错误。
 包mypack;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts2.ServletActionContext;
import org.apache.struts2.dispatcher.SessionMap;

import com.opensymphony.xwork2.ActionSupport;
import com.sun.javafx.collections.MappingChange.Map;

public class LoginAction extends ActionSupport {
    private static final long serialVersionUID = 1L;
    private String name;
    private String password;
    private String email;
    private String phone;
    private int id;
    SessionMap<String,String> sessionmap;  



    public int getId1() {
        return id;
    }
    public void setId1(int string) {
        this.id=string;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
    public String getPassword() {
        return password;
    }
    public void setPassword(String password) {
        this.password = password;
    }

    public String getEmail() {
        return email;
    }
    public void setEmail(String email) {
        this.email = email;
    }
    public String getPhone() {
        return phone;
    }
    public void setPhone(String phone) {
        this.phone = phone;
    }
     public String Register()
     {
     int i=UserDAO.insertData(this);  
        if(i>0){
        return "success";
     }

        return "error";  
     }  


    public String Login() throws ClassNotFoundException 
    {
        HttpServletRequest req = ServletActionContext.getRequest();
        setName(req.getParameter("name"));
        setPassword(req.getParameter("pass"));
         if(LoginDAO.chechLogin(getName(),getPassword())){  
                return "success";  
            }  
            else{  
                return "error";  
            }  
    }

public String Update() throws Exception {

HttpServletRequest req = ServletActionContext.getRequest();
setName(req.getParameter("name"));
setPassword(req.getParameter("password"));
setPassword(req.getParameter("email"));
setPassword(req.getParameter("phone"));




LoginAction user = null;
if (LoginDAO.updateData(user))
{
return "success";
}
else
return "error";
}
}

    /*public void setSession(Map map) {  
        sessionmap=(SessionMap)map;  
        sessionmap.put("Login","true");  
    } 
     public String Update(){

         UserDAO.updateData(this);  

            return "success";  


        }     
}
    /*  public String Login(){

            if(UserDAO.chech1Login(name,password)){  
                    return "success";  
                }  
                else{  
                    return "error";  
                }  
        }

/public String Delete(){

LoginAction user = null;
if(UserDAO.deleteData(user)){

                    return "success";  

    }
   else
         return "error";
         }
}
}*/

1 个答案:

答案 0 :(得分:0)

检查更新()方法。在更新用户之前,您将其设置为 null