或許是慣性思維,在mybatis使用foreach循環調用的時候,很多時候都是傳一個對象,傳一個List的情況很少,是以寫代碼有時候會不注意就用慣性思維方法做了。
今天向sql傳參,傳了一個List作為參數,然後在xml裡再foreach循環調用。然後報錯資訊如:
mybatis foreach報錯It was either not specified and/or could not be found for the javaType
Type handler was null on parameter mapping for property '__flowStepCode_0
Mapper接口
List<AllocationHandlerInfoVo> listAllocatedHandlerInfo(@Param("flowStepCodeList")List<ApprStepModel> flowStepCodeList);
複制
原來是這樣:
#{flowStep},
處理方法,換成
#{flowStep.flowStepCode}
,List是個集合來的,要注意,寫部落格記錄
<if test="flowStepCodeList != null and flowStepCodeList.size() > 0">
fh.flow_step_code in
<foreach collection="flowStepCodeList" item="flowStep" index="index" open="(" close=")" separator=",">
#{flowStep.flowStepCode}
</foreach>
</if>
複制