Mybatis-There is no getter for property named 'id' in 'class java.lang.String'
<mapper namespace="cn.telchina.standard.mapper.SysOrgnMapper"> <!-- <![CDATA[sql ]]> 尽量每个sql必须写,防止有些特殊字符对sql语句造成的破坏 --> <select id="queryOrgnList" resultType="SysOrgnModel"> <![CDATA[ select t.* from base.sys_organization t ]]> <if test="jgid!=null "> <![CDATA[ where t.fjgid=#{jgid} order by jgbh ]]> </if> <if test="jgid==null "> <![CDATA[ where t.fjgid is null order by jgbh ]]> </if> </select> </mapper>
public List<SysOrgnModel> queryOrgnList( Integer jgid);
会触发Mybatis的错误。
解决办法:public List<SysOrgnModel> queryOrgnList(@Param("jgid") Integer jgid);
原因:
问题分析:Mybatis默认采用ONGL解析参数,所以会自动采用对象树的形式取string.id值,引起报错。
另外一种解决办法: