<select id="findNoteByID" parameterType="string" resultType="note">
SELECT * FROM TABLE
<where>
<choose>
<when test="id != null and id !='' ">id = #{id}</when>
<otherwise>1=2</otherwise>
</choose>
</where>
</select>
在测试时报错:There is no getter for property named 'id' in 'class java.lang.String'
问题分析:Mybatis默认采用ONGL解析参数,所以会自动采用对象树的形式取string.id值,引起报错。
解决方法: public Note findNoteByID(@Param(value="id") String id);说明参数值。
本文探讨了在使用Mybatis时遇到的参数解析错误问题,分析了错误原因,并提供了具体的解决方法,帮助开发者理解如何正确地定义参数和类型,避免此类错误的发生。
322

被折叠的 条评论
为什么被折叠?



