问题:
执行查询时报错:There is no getter for property named '*' in 'class java.lang.String
原因:
传过去的参数为识别。本例为
public interface TestMapper{
List<Base> findAllBase(String search);
}
<select id="findAllBase" resultType="*.Base" parameterType="String">
select id,name from t_base
where 1=1
<if test="search != null and search != ''">
AND name LIKE CONCAT('%',#{search },'%')
</if>
order by id
</select>
解决方法:
1、在mapper接口增加参数设置,如下:
public interface TestMapper{
List<Base> findAllBase(@Param(value="search") String search);
}
2、将具体报错的变量名更换为_parameter,如下:
<select id="findAllBase" resultType="*.Base" parameterType="String">
select id,name from t_base
where 1=1
<if test="_parameter!= null and _parameter!= ''">
AND name LIKE CONCAT('%',#{search },'%')
</if>
order by id
</select>
网友评论