这里记录两个思路:

首先是写一个不能执行的代码。

    <select id="query" parameterType="map" resultType="Desk">
        select * from desk
        <where>
            <include refid="query_desk_where"/>
        </where>
        limit #{pc-1}*#{ps},#{pc}*#{ps}
    </select> 

limit字句中是不允许运算的,而#{}表示的是一个占位符,所以报错sql语句放到编辑器里面也不能执行

 

解决方案1:

  将#{}变成${},也就是相当于limit后面的值是定值,sql语句是拼接而成的而不是占位符赋值运算:

    <select id="query" parameterType="map" resultType="Desk">
        select * from desk
        <where>
            <include refid="query_desk_where"/>
        </where>
        limit ${(pc-1)*ps},${pc*ps}
    </select> 

    或者使用先在service中处理得到start和end然后再传入

相关文章:

  • 2021-04-21
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-29
  • 2022-12-23
猜你喜欢
  • 2021-04-08
  • 2021-09-18
  • 2021-11-29
  • 2021-12-28
  • 2022-12-23
  • 2021-11-19
  • 2022-12-23
相关资源
相似解决方案