How can I sort a List several different ways in a JSP?

后端 未结 3 1947
栀梦
栀梦 2020-12-16 13:49

I have a list of Player objects getting passed into a JSP from a controller, and I want to display them in a couple of different ways on the same page:

  • a menu
3条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-16 14:43

    I'd recommend having two sorted lists in the model. The lists will just contain object references, so it's not a big space issue, and I personally don't like doing that sort of work in the JSPs. If you presort them, it doesn't matter how many times the page is viewed in normal navigation, and as long as the lists don't change, you won't have to incur the sort overhead.

提交回复
热议问题