java.sql.SQLException:Parameter index out of range (1>number of parameters, which is 0)

  执行根据某条件查询数据,报错如下:

  网上搜索了下,说是mysql预查询语句中的问号个数和传入的参数个数不符。再看自己的mybatis代码:

            <if test="model != null and model != ''">
              and model like CONCAT("%", "#{model}", "%")
            </if>

  发现参数#{model}加上了引号,去掉引号就OK了。

原文地址:https://www.cnblogs.com/GreenMountain/p/9993377.html