日期:2014-05-17  浏览次数:20674 次

有关mybatis传入参数的问题!贼急! 贼急!
AMapper.java中定义

public int method(String str); ---------------1

AMapper.xml中定义

<select id="method" parameterType="java.lang.String">

  select count(*) from table 
  <if test = "str != null"> ----------------2
  where colume = #{str}
  </if>
</select>

以上形式 在执行的时候会报异常 提示 str no getter………………

但是 如果 在 1 处 改为 method(@Param str) 即可正常
或 去掉2 处的判断也可正常

求教 其中的原理!!!!!!!!!

大侠帮忙啊!!!!

------解决方案--------------------
<if test = "#{str != null}"> ----------------2
where colume = #{str}
</if>