mybaits错误解决:There is no getter for property named 'province' in class 'java.lang.String'

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_39135287/article/details/80468247

在使用mybaitis传参数的时候,如果仅传入一个类型为String的参数,且在 xml文件中使用if语句来判断是否在where条件语句中加入该条件时,需给这个方法的参数加上@Param(value=“province”),就能够解决问题

代码如下

Mapper接口

List<Scenery> selectSceneryByAllOrProvince(@Param("province") String province);

Mapper.xml文件

<select id="selectSceneryByAllOrProvince" resultMap="ResultMapWithBLOBs" parameterType="java.lang.String">
		select
		<include refid="Base_Column_List" />
		,
		<include refid="Blob_Column_List" />
		from scenery
		<where>
		   <if test="province!=null and province!=''">
		     and province = #{province,jdbcType=VARCHAR}
		   </if>
		</where>
		order by createtime desc
	</select>


之前在使用mybaitis传参数的时候,仅传入一个参数,是不需要给参数添加@Param()注解的,因为之前传递一个参数时,在Mapper.xml里,是没有使用if语句来判断是否在where条件语句中加入该条件的,所以不需要添加@Param()注解的。


猜你喜欢

转载自blog.csdn.net/qq_39135287/article/details/80468247
今日推荐