JSTL forEach reverse order

后端 未结 5 1260
眼角桃花
眼角桃花 2020-12-06 04:16

Using JSTL\'s forEach tag, is it possible to iterate in reverse order?

5条回答
  •  佛祖请我去吃肉
    2020-12-06 05:14

    You could also consider rolling a custom JSTL function that returned a reversed copy of your list, backed by something like this:

    public static  List reverse(List list) {
        List copy = Collections.emptyList();
        Collections.copy(copy, list);
        Collections.reverse(copy);
        return copy;
    }
    

    Doesn't work for Collections, but as mentioned in another answer, the concept of ordering is a bit vague for some collections.

提交回复
热议问题