c:forEach don't repeat same values when already present in previous row

后端 未结 3 1122
無奈伤痛
無奈伤痛 2021-01-16 20:02

I\'m having some trouble with this...

I have code like this:

Market market = new market();
List list = marketService.getMarketItemList         


        
3条回答
  •  不知归路
    2021-01-16 20:39

    If you cannot create a map, so if you need to work with a list, you can check the previous value.

    You can create a variable containing the previous value and check for that:

    
    
      ${type eq previousType ? '-same-' : type}

    Or, you could use the index using the varStatus attribute:

    
    
      ${status.index gt 0 and types[status.index - 1] eq types[status.index] ? '-same-' : type}

    Here you could also use not status.first instead of status.index gt 0.

    Both will output:

    fruit
    -same-
    vegetable
    

提交回复
热议问题