mapper.xml
<insert id="save" keyProperty="id"
useGeneratedKeys="true">
/*设置俩个属性就可以了keyProperty="id"
useGeneratedKeys="true"*/
insert into fileupload(type,url,name,fileid,dup,filesize,user) VALUES(
#{type},
#{url},
#{name},
#{fileid},
#{dup},
#{filesize},
#{user}
)
</insert>
test
@Test
public void test2() throws Exception {
FileUpload t = new FileUpload();//创建一个对象
t.setFileid(3L);//设置值
t.setFilesize(11D);
t.setUser("goudan");
mapper.save(t);
//保存后get方法就可获取到id
System.out.println(t.getId());
}