1070148808 / huaweiStudyJava

0 stars 0 forks source link

ssm框架 #15

Closed 1070148808 closed 5 years ago

1070148808 commented 5 years ago

http://how2j.cn/k/ssm/ssm-tutorial/1137.html?tid=77#step7522

1070148808 commented 5 years ago

mybatis 传入string报错getter啥的,需要将调用的变量名换成_parameter

There is no getter for property named ‘type ’ in ‘class java.lang.String’ 因为MyBatis要求如果参数为String的话,不管接口方法的形参是什么,在Mapper.xml中引用时需要改变为_parameter才能识别 :

<select id="findByAccountType " parameterType="string" resultType="account">
  select *
  form account
  <where>
    <if test ="_parameter!= null">
      type=#{_parameter}
    </if>
  </where>
</select>