在*DAO中写了这样一个方法
public boolean get(String id, String password, String amount, String vdate) {
Connection con = dbc.getcon();
try {
PreparedStatement pstat = con
.prepareStatement("insert into get values('" + id + "','"
+ password + "','" + amount + "','" + vdate + "')");
int count = pstat.executeUpdate(); if (count > 0) {
issuc = true;
} pstat.close();
con.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} return issuc;
}在action类中调用它
public String get(){
dao.get(account.getId(),account.getPassword(),account.getAmount(),account.getVdate());
return SUCCESS;
}参数通过jsp页面传的报错java.lang.NullPointerException ,不知道怎么回事
public boolean get(String id, String password, String amount, String vdate) {
Connection con = dbc.getcon();
try {
PreparedStatement pstat = con
.prepareStatement("insert into get values('" + id + "','"
+ password + "','" + amount + "','" + vdate + "')");
int count = pstat.executeUpdate(); if (count > 0) {
issuc = true;
} pstat.close();
con.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} return issuc;
}在action类中调用它
public String get(){
dao.get(account.getId(),account.getPassword(),account.getAmount(),account.getVdate());
return SUCCESS;
}参数通过jsp页面传的报错java.lang.NullPointerException ,不知道怎么回事
在action里你的get方法有返回值的,试试这样;
if(dao.get(account.getId(),account.getPassword(),account.getAmount(),account.getVdate()){
return SUCCESS;
}return INPUT;
试试
先保证你jsp都有传值过来,并且表单里的属性要跟account类里的属性,名称要一个样;
然后你要保证在这个action里
定义了private Account account;
并生成了set ,get 的方法;
这时account里才有值;
dao.get(account.getId(),account.getPassword(),account.getAmount(),account.getVdate())//这里看下account是否有值;