这是前端输入的数据
前端AJAX传入数据
后台Controller层代码
service层
sql输出语句表示这两层都能接受数据
但是插入语句找不到数据
==> Preparing: insert into staff(id,sname,sex,birthday,sid,depart_id,post_id,entrydate,joinworkdate,workform, ,staffsource,politicalstatus,nation,nativeplace,stel,semail,sheight,bloodtype,maritalstatus, registeredresidence,education,degree,university,major,graduationdate,startdate,enddate,status,peroidopdate) values (null, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,?,? ,'正常' ,?)
下面是Dao层代码
@Repository("staffDao")
@Mapper
public interface StaffDao {
public int addStaff(Staff staff);
}
mybatis-conf.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration
PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
<mappers>
<mapper resource="com/mybatis/AdminMapper.xml"/>
<mapper resource="com/mybatis/DepartmentMapper.xml"/>
<mapper resource="com/mybatis/PostMapper.xml"/>
<mapper resource="com/mybatis/StaffMapper.xml"/>
</mappers>
</configuration>
StaffMapper.xml代码如下
数据库结构
Staff类
public class Staff {
private Integer id;
private String sname;
private String sex;
private Date birthday;
private String birthday1;
private String sid;
private Integer depart_id;
private Integer post_id;
private Date entrydate;
private String entrydate1;
private Date joinworkdate;
private String joinworkdate1;
private String workform;
private String staffsource;
private String politicalstatus;
private String nation;
private String nativeplace;
private String stel;
private String semail;
private Double sheight;
private String bloodtype;
private String maritalstatus;
private String registeredresidence;
private String education;
private String degree;
private String university;
private String major;
private Date graduationdate;
private String graduationdate1;
private Date startdate;
private String startdate1;
private Date enddate;
private String enddate1;
private String status;
private String dname;
private String pname;
//get和set省略
}