mybatis中Could not set parameters for mapping异常


在使用mybatis时报Could not set parameters for mapping异常。

最初以为是自己动态sql写的有问题,反复修改,查看语法标签。

最后发现是注释的问题。

在xml文档中,哪怕是sql statement中也不能使用/* */的注释方法。

如:

 1 <select id="listByCondition" parameterType="user" resultType="user">
 2         select *
 3         from sys_user
 4         <where>
 5             /*where id = #{id};*/
 6             <if test="username!=null and username!=''">
 7                 and username like #{username}
 8             </if>
 9             <if test="email !=null and email!=''">
10                 and email like #{email}
11             </if>
12         </where>
13     </select>

删掉/*where id = #{id};*/注释后,异常消除。

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM