在这种情况下:
<select id="selectByTitle" parameterType="String" resultMap="ad">
select id,title,img_file_name,link,weight from ad
<where>
<if test="title!=null and title!=''">title like "%"#{title}"%"</if>
</where>
</select>
注意看,是在if test=验证的时候发生的 “There is no getter for property named in ‘class java.lang.String’”,
而并非是#{title} 的时候发生的错误。
解决办法:
1:if中的title改为_parameter。_parameter是mybatis中的内置参数,代表单个参数。
<if test="_parameter!=null and _parameter!=''">...</if>
2:在Dao层中的方法参数中,加上@Param(value="title")注解。