开发者

In Ibatis, how does one write a nested Iterate tag to loop through a two-dimensional array?

开发者 https://www.devze.com 2023-01-12 14:45 出处:网络
I was troubleshooting the following code and was unable to find an answer, so I figured I woul开发者_运维知识库d document my solution.

I was troubleshooting the following code and was unable to find an answer, so I figured I woul开发者_运维知识库d document my solution.

The problem was:

<iterate property="twoDimArray" prepend="and (" close=")" conjunction="or">
    <iterate property="twoDimArray[]" open="(" close=")" conjunction="and">  
        $twoDimArray[][].columnName$ = #twoDimArray[][].value#  
    </iterate>  
</iterate>  

Resulted in an error: There is no READABLE property named 'columnName' ...


I found that I needed to reference the second array as a property of the first:
$twoDimArray[].[].columnName$ = #twoDimArray[].[].value#

0

精彩评论

暂无评论...
验证码 换一张
取 消