以上是思维导图
首先要导入jar包 然后在web。xml中配置一下
public void add(Student student) throws Exception {
String sql = "insert into t_student values(?,?,?,?,?)";
super.executeUpdate(sql, student, new String[] {"sid","sname","sname_pinyin","age","remark"});
}
public void delete(Student student) throws Exception {
String sql = "delete from t_student where bid = ?";
super.executeUpdate(sql, student, new String[] {"sid"});
}
public void edit(Student student) throws Exception {
String sql = "update t_student set sname = ?,sname_pinyin = ?,age=?,remark=? where sid = ?";
super.executeUpdate(sql, student, new String[] {"sname","sname_pinyin","age","remark","sid"});
}
public List<Student> list(Student student,PageBean pageBean) throws Exception {
String sql = "select * from t_student where 1=1 ";
String sname = student.getSname();
String sid = student.getSid();
if(StringUtils.isNotBlank(sname)) {
sql += " and sname like '%"+sname+"%'";
}
System.out.println(sid);
if(!sid.equals("")) {
sql += " and sid = " + sid;
}
return super.executeQuery(sql, Student.class, pageBean);
}
上面是dao方法中的增删查改方法