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

用mybatis查询时,传入一个字符串传参数,且进行判断时,会报

 

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



错误写法:

    <select id="queryAll" parameterType="String" resultType="ComDTO">
        select
            userId,openid,wxName,wxImg,name,sex,age,telNum,checkCode,playNum,otherNum,
            user.projectId projectId,projectName,projectSimName,projectNum,user.createTime createTime
        from com_user user, com_project project 
        <where>
            user.projectId = project.projectId
            <if test="projectId != null and projectId !=''">
                and user.projectId=#{projectId}
            </if>
        </where>
        order by userId desc
    </select>

 



  需要修改成:
  

    <select id="queryAll" parameterType="String" resultType="ComDTO">
        select
            userId,openid,wxName,wxImg,name,sex,age,telNum,checkCode,playNum,otherNum,
            user.projectId projectId,projectName,projectSimName,projectNum,user.createTime createTime
        from com_user user, com_project project 
        <where>
            user.projectId = project.projectId
            <if test="_parameter != null and _parameter !=''">
                and user.projectId=#{_parameter}
            </if>
        </where>
        order by userId desc
    </select>

 



  不管你的参数是什么,都要改成"_parameter"

posted @ 2015-10-20 16:49  路途寻码人  阅读(514)  评论(0编辑  收藏  举报