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中

 

相关文章:

  • 2021-07-07
  • 2022-12-23
  • 2021-11-21
  • 2021-06-11
  • 2021-05-14
  • 2021-12-04
猜你喜欢
  • 2021-11-27
  • 2021-12-15
  • 2021-12-15
  • 2023-03-19
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案