1. Add the properties "useGeneratedKeys" and "keyProperty" to the Mybatis Mapper file, where keyProperty is the property name of the Java object, not the field name of the table
<insertid="insert"parameterType="实体名"useGeneratedKeys="true"keyProperty="id">insert into system(name) values(#{name})
</insert>
Second, in the controller
The id when adding the current row of data is obtained through the entity name.id