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)
1、原始java
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(對象)中spring
若是是直接傳單個參數會報上面的錯。apache
解決方法:mybatis
public int getSjNumbySource(Map map);
而後在controller層將數據source放進map中spa