org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.reflection.ReflectionException:
There is no getter for property named 'source' in 'class java.lang.String'
at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:75)
at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:371)
at com.sun.proxy.$Proxy20.selectOne(Unknown Source)
一、原始
DAO接口方法:
public int getSjNumbySource(String source);
mybatis的XML配置文件
<select id="getSjNumbySource" resultType="java.lang.Integer" parameterType="java.lang.String"> SELECT COUNT(*) FROM t_apb_res_info WHERE RES_KIND='FL3' AND RES_TYPE='LX7' <if test="source != null and source !=''"> AND RES_SOURCE=#{source,jdbcType=VARCHAR} </if> </select>
mybatis中如果用了if那么传进来的参数不能直接单独传入,要封装到map或vo(对象)中
如果是直接传单个参数会报上面的错。
解决方法:
public int getSjNumbySource(Map map);
然后在controller层将数据source放进map中