Set sorting problem under ssh framework

When the student information of the entire class needs to be displayed, the class object is usually passed to the view layer. When the class object is used to get the collection of students, it is usually the set collection (${classs.student}t represents the collection of all students). ), and Hibernate took it by itself. If you want to sort students by an attribute?

The first solution is : don't pass the class object, pass the student list directly, sort the list first and then give it to the view

The second solution is to sort the set before the getStudents method of the class returns the set, which involves the sorting of the set. You can convert the set to the list, sort the list, and then convert the list to a TreeSet to achieve the sorting of the set.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324938229&siteId=291194637