is it possible to iterate two items simultaneously using foreach in jstl?

后端 未结 2 861
谎友^
谎友^ 2020-12-28 09:33

I have two items from my model and I want to iterate them at the same using jstl foreach. how can I achieve this using a correct syntax?

2条回答
  •  自闭症患者
    2020-12-28 10:04

    You can call varStatus.index to get the index of the current round of iteration, and then use it as a lookup for the second list.

    For example, if you have two lists people.firstnames and people.lastnames you can do:

    
      
          ${p}
          ${people.lastnames[status.index]}
      
    
    

提交回复
热议问题