Mybatis异常Available parameters are [arg1, arg0, param1, param2]

org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.binding.BindingException: Parameter 'role_id' not found. Available parameters are [arg1, arg0, param1, param2]

这是因为在你的mybatis的Mapper接口方法传入了多个参数,如

 List<Map<String,Object>> loadRight(String role_id,String parent_code);

你的配置文件如:

    <select id="loadRight" resultType="hashmap" >
        select  rf.rf_role_id,y.right_code,y.right_text,y.right_url,y.right_parent_code from  sys_role_right rf inner JOIN sys_right y on y.right_code=rf.rf_right_code
          where  rf.rf_role_id=#{role_id}  and  y.right_parent_code=#{parent_code}

    </select>

所导致的解决方法为:

修改xml文件

1.使用arg1, arg0

代码如下:

    <select id="loadRight" resultType="hashmap" >
        select  rf.rf_role_id,y.right_code,y.right_text,y.right_url,y.right_parent_code from  sys_role_right rf inner JOIN sys_right y on y.right_code=rf.rf_right_code
          where  rf.rf_role_id=#{arg0}  and  y.right_parent_code=#{arg1}

    </select>

1.2使用param1, param2

   <select id="loadRight" resultType="hashmap" >
        select  rf.rf_role_id,y.right_code,y.right_text,y.right_url,y.right_parent_code from  sys_role_right rf inner JOIN sys_right y on y.right_code=rf.rf_right_code
          where  rf.rf_role_id=#{param1}  and  y.right_parent_code=#{param2}

    </select>

2.修改java代码

 List<Map<String,Object>> loadRight(@Param("role_id") String role_id,@Param("parent_code") String parent_code);

 

 

 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值