mybatis使用动态sql时报错:There is no getter for property named '*' in 'class java.lang.String

时间:2023-02-05 17:08:50

mybatis使用动态sql:如<if><when><trim><where>,而parameterType又恰好是string,

如下:


<select id="getP_VListWithParams" parameterType="string" resultMap="p_vMap">
select * from p_v
<where>
<if test="<span style="background-color: rgb(51, 204, 0);"><strong><span style="font-size:24px;">p_v_id</span></strong></span>!= null">
locate (#{p_v_id},p_v_id)
</if>
</where>
</select>

此时,如果程序调用到getP_VListWithParams方法,则会报错:There is no getter for property named '*' in 'class java.lang.String


临时性的解决方案,把<if>检测语句中的p_v_id替换成_parameter,即:

<span style="background-color: rgb(240, 240, 240);"><select id="getP_VListWithParams" parameterType="string" resultMap="p_vMap">
select * from p_v
<where>
<if test="</span><span style="font-size:24px;"><strong><span style="background-color: rgb(0, 153, 0);">_parameter</span><span style="color:#33cc00;background-color: rgb(240, 240, 240);"> </span></strong></span><span style="background-color: rgb(240, 240, 240);">!= null">
locate (#{p_v_id},p_v_id)
</if>
</where>
</select></span>


即可解决上述报错,根本原因,请参考blog:

http://blog.csdn.net/qing_gee/article/details/47122227