I want to display the key value bean based on sorting of value in Struts 2

前端 未结 2 1469
猫巷女王i
猫巷女王i 2021-01-27 12:56

I want to display the key value bean based on sorting of value in Struts 2.



        
相关标签:
2条回答
  • 2021-01-27 13:30

    You can try and sort the values in Action class itself, so when select is rendered the list will appear sorted

    0 讨论(0)
  • 2021-01-27 13:31

    The List is an ordered collection. If it contains elements sorted by the key property then other the value property remains unsorted unless it's the same property. To make it sorted on another property you can sort the list with the comparator.

    Collections.sort(myList, myComparator);
    

    or you can use s:sort tag like in this example. And you only have to provide the comparator in the action class.

    0 讨论(0)
提交回复
热议问题