mybatis,foreach,找不到參數(shù)報錯問題及解決
mybatis,foreach,找不到參數(shù)報錯
Resolved [org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.

#{} 內(nèi)部名字要和 item 的名字一致
解決接口傳入List或數(shù)組后,mybatis找不到參數(shù)報錯
廢話少說,上代碼,接口原來寫成了:
List<BugCcDO> getBugCcs(Long[] workIds);
mapper文件配置:
<select id="getBugCcs" resultType="com.changhong.cloud.tmplatform.entity.bug.BugCcDO">
SELECT
<include refid="All_CcLog_Column_Values"/>
FROM
pms_cc_log
WHERE
<if test="workIds != null">
work_id IN
<foreach item="workId" index="index" collection="workIds" open="(" separator="," close=")">
#{workId}
</foreach>
</if>
</select>
然后一直報錯:
org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.binding.BindingException: Parameter 'workIds' not found. Available parameters are [array]
找到的解決方法是:
修改接口傳參為:
List<BugCcDO> getBugCcs(@Param("workIds") Long[] workIds);總結
以上為個人經(jīng)驗,希望能給大家一個參考,也希望大家多多支持腳本之家。
相關文章
mybatis?plus框架@TableField注解不生效問題及解決方案
最近遇到一個mybatis plus的問題,@TableField注解不生效,導致查出來的字段反序列化后為空,今天通過本文給大家介紹下mybatis?plus框架的@TableField注解不生效問題總結,需要的朋友可以參考下2022-03-03
解決@PathVariable出現(xiàn)點號.時導致路徑參數(shù)截斷獲取不全的問題
這篇文章主要介紹了解決@PathVariable出現(xiàn)點號.時導致路徑參數(shù)截斷獲取不全的問題,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教2021-08-08

