使用mybatis模糊查询的时候,mapper的方法为:
List<Scientific> selectScientificBytitle(String title);//模糊查询
xml的写法是:
<select id="selectScientificBytitle" parameterType="java.lang.String" resultType="com.lancoo.primaryedu.entity.domain.Scientific"> select <include refid="Base_Column_List"></include> from scientific_case where 1=1 <if test="title != null "> and title like concat('%',#{title,jdbcType=VARCHAR},'%') </if> </select>
访问的时候出现报错:There is no getter for property named 'XXX' in 'class java.lang.String'
解决方法是将mapper里面的参数使用注解形式,不然是映射不到xml里面去的。
List<Scientific> selectScientificBytitle(@Param("title") String title);//模糊查询
这样一来,就可以解决!!!