在使用mybatis的时候报了一个这样的错误。其实知道是因为参数传递的不对,但是一直忘记了如何修改。所以在这里整理一下:
传递参数:
(1)传递一个基本数据类型的数据
通过parameterType来指定参数的类型
<select id="selectLimitSays" resultMap="saywordsMap" parameterType="Integer">
select * from s_contents limit #{page},5
</select>
(2)传递多个基本数据类型
在传递多个基本数据类型的时候,不可以指定parameterType的类型。而且在接收参数的时候需要使用规定的参数名称。
默认的是Available parameters are [arg2, arg1, arg0, param3, param1, param2]
<select id="selectByClassId" resultMap="saywordsMap">
select * from s_contents where con_type=#{arg0} limit #{arg1},5
</select>
(3)传递一个对象类型的数据
<insert id="save" parameterType="com.lxb.entity.Saywords" useGeneratedKeys="true" keyPropert