mybatis There is no getter for property named 'xx' in 'class java.lang.String

错误配置:

  mybatis的xml

 1    <select id="getDoctorList" resultMap="BaseResultMap" parameterType="java.lang.String">
 2     select 
 3     <include refid="Base_Column_List" />
 4     from doctor
 5     where 1=1
 6     <if test="name != null" >
 7     and name = #{name}
 8     </if>
 9     order by id
10   </select>

  dao

1 List<Doctor> getDoctorList(String name);

修改方法一(推荐)

  xml不改,dao加上param注解

1 List<Doctor> getDoctorList(@Param(value="name")String name);

修改方法二

  dao不改,xml的参数用“_parameter”来代替

 1    <select id="getDoctorList" resultMap="BaseResultMap" parameterType="java.lang.String">
 2     select 
 3     <include refid="Base_Column_List" />
 4     from doctor
 5     where 1=1
 6     <if test="_parameter != null" >
 7     and name = #{_parameter}
 8     </if>
 9     order by id
10   </select>

 

posted on 2016-06-08 15:45  执念saying  阅读(286)  评论(0编辑  收藏  举报

导航