MyBatis中提示:invalid comparison: java.util.LinkedHashMap and java.lang.String


场景

在使用MyBatis传递多个参数并且传递的参数作为判断条件时提示:

invalid comparison: java.util.LinkedHashMap and java.lang.String

 

 

注:

博客:
https://blog.csdn.net/badao_liumang_qizhi
关注公众号
霸道的程序猿
获取编程相关电子书、教程推送与免费下载。

实现

在Mapper文件中使用动态sql时,对传递的参数进行判断时使用了如下的

        <where>
            <if test="#{lx} != null  and #{lx}!= ''"> and g.ryfl = #{lx}</if>
        </where>

在test语句中使用了#{lx}

正确应该是直接使用参数名

        <where>
            <if test="lx != null  and lx!= ''"> and g.ryfl = #{lx}</if>
        </where>

 


免责声明!

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



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