我正在使用 Ibatis 2,我在詢問如何打印對象數組(因為官方文檔已經消失)。這是類似于我擁有的示例數據:[ { "firstStr": "D392", "secondStr": "N3895" }, { "firstStr": "D624", "secondStr": "M2435" }, { "firstStr": "T4543", "secondStr": "K9345" }]此數據定義為ArrayList. 數組中的對象定義為Map:Map<String,String> data = new HashMap();data.put("firstStr","D392");data.put("secondStr","N3895");...ArrayList<Map> insert = new ArrayList<Map>();insert.add(data);我需要使用<iterate>(因為在我的版本中 foreach 不可用)在 sql 模板中映射此數據。我目前擁有的:<select parameterClass="ArrayList"> select * from something where str IN <iterate property="insert"> #[].firstStr$, #[].secondStr# </iterate></select>我收到以下錯誤:String index out of range: -1這個問題的原因可能是什么?編輯:不要讓我更新或使用其他依賴項,因為由于軟件限制這是不可能的!
1 回答

互換的青春
TA貢獻1797條經驗 獲得超6個贊
實際上你是對的,你的代碼中只有一個小錯字。property="insert"在您的聲明中刪除<iterate>:
<select parameterClass="ArrayList">
select * from something
where str IN
<iterate>
#[].firstStr$, #[].secondStr#
</iterate>
</select>
添加回答
舉報
0/150
提交
取消