I have code like this in a GSP:
<g:each in="${cifUserInstance.cif?.servicePackage?.transactions?.collect{it.service}}" status="i" var="transaction">
But the resulting data is not sorted; they are displayed randomly. How can I sort the data using the code above?
Try:
<g:each in="${cifUserInstance.cif?.servicePackage?.transactions?.collect{it.service}.sort()}" status="i" var="transaction">
BTW, it's better to prepare all data in controller, and use view's gsp only to show result data
这是黑暗中的一枪,却看不到“交易”和“服务”的模样,但是您可以尝试一下,
<g:each in="${cifUserInstance.cif?.servicePackage?.transactions?.service.sort()}" status="i" var="transaction">
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.