Parameter index out of range (2 > number of parameters, which is 1).原因及处理

以你之姓@ 2023-10-09 15:06 140阅读 0赞

1、在运行ssm项目时,报Parameter index out of range (2 > number of parameters, which is 1)异常

2、原因
mapper文件中的动态SQL中select标签中有快捷方式注释的语句

  1. <select id="findById" parameterType="integer" resultMap="findByIdResultMap">
  2. select *
  3. from t_setmeal
  4. where id = #{id}
  5. # SELECT
  6. # s.*,c.id gid,c.name gname,c.helpCode ghelpCode,c.code gcode,c.attention gattention,c.sex gsex,c.remark gremark,i.id iid,i.name iname,i.code icode, i.sex isex, i.age iage, i.price iprice, i.type itype, i.attention iattention, i.remark iremark
  7. # FROM
  8. # t_setmeal s
  9. # LEFT JOIN t_setmeal_checkgroup sc ON s.id = sc.setmeal_id
  10. # LEFT JOIN t_checkgroup c ON sc.checkgroup_id = c.id
  11. # LEFT JOIN t_checkgroup_checkitem cc ON c.id = cc.checkgroup_id
  12. # LEFT JOIN t_checkitem i ON cc.checkitem_id = i.id
  13. # WHERE s.id = #{id}
  14. </select>

3、处理
删除标签中快捷键注释的语句或修改成正确的注释语句

  1. <select id="findById" parameterType="integer" resultMap="findByIdResultMap">
  2. select *
  3. from t_setmeal
  4. where id = #{id}
  5. </select>

发表评论

表情:
评论列表 (有 0 条评论,140人围观)

还没有评论,来说两句吧...

相关阅读