Mybatis异常There is no getter for property named 'XXX' in 'class java.lang.String'

1.当入参为 string类型时 (包括java.lang.String.) 

我们使用#{xxx}引入参数.会抛异常There is no getter for property named 'XXX' in 'class java.lang.String'

<select id="xxxx" resultType="int" parameterType="string">

select count(*) from TB_EMPC_BOOKING_ORDER T

where (t.state = '1' or t.state = '2')

and t.appointmenttime = #{state}

</select>

2.解决方法一:把#{xxx}修改为 #{_parameter} 即可

<select id="getBookingCount" resultType="int" parameterType="string">

select count(*) from TB_EMPC_BOOKING_ORDER T

where (t.state = '1' or t.state = '2')

and t.appointmenttime = #{_parameter}

</select>

3.解决方法二:可以在方法中提前定义:

public int  methodName(@Param(value="state") String state ){

  ...

}
上一篇:纯小白入手 vue3.0 CLI - 2.3 - 组件 home.vue 中学习指令和绑定


下一篇:理解Vue 2.5的Diff算法