在mapper文件insert标签中加上如下2个参数,而后便可以通过entity.getId()方法获得。注意:这里的“id”对应的是model里的属性,而不是数据库的字段id
useGeneratedKeys="true" keyProperty="id" //id 对应改为model里的id属性
在mapper文件insert标签中加上如下2个参数,而后便可以通过entity.getId()方法获得。注意:这里的“id”对应的是model里的属性,而不是数据库的字段id
useGeneratedKeys="true" keyProperty="id" //id 对应改为model里的id属性