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

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了。

相关文章:

  • 2021-09-12
  • 2021-06-27
  • 2021-10-03
  • 2021-12-05
  • 2022-01-14
  • 2021-07-12
  • 2022-12-23
  • 2021-10-13
猜你喜欢
  • 2022-12-23
  • 2021-09-13
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案