1. 程式人生 > >mybatis foreach報錯It was either not specified and/or could not be found for the javaType Type handler

mybatis foreach報錯It was either not specified and/or could not be found for the javaType Type handler

或許是慣性思維,在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>