mapper文件
List<Supplier> queryName(String supplierName);
mapper.xml文件
<select id="queryName" resultMap="BaseResultMap">
select *
from supplier
<where>
<if test="supplierName != null and supplierName.length() > 0">supplier_name like "%"#{supplierName}"%"</if>
</where>
</select>
当使用Mybatis<where>
中的<if>
标签时,传入一个参数会报以下错误
There is no getter for property named ‘supplierName’ in ‘class java.lang.String’
解决办法:
加@Param注解
mapper文件
List<Supplier> queryName(@Param("supplierName") String supplierName);