I am returning a list of dates,list of size and list of months from controller action to gsp..i want each value in dates,size and months list to be displayed in 3 diffe开发者_StackOverflow社区rent fields of each row.how to achieve it?
Advance thanks
laxmi.P
Suppose dlist
is the list of dates you are passing from the controller/action, then in gsp:
<table>
<g:each in="${dlist}">
<tr>Date: ${it}</tr>
</g:each>
</table>
or
<table>
<g:each var="date" in="${dlist}">
<p>date: ${date}</p>
</g:each>
</table>
Enjoy
UPDATE:
To achieve this thing, I think it would be better to pass list of maps to gsp page, e.g
def index = {
def data = [[date:"d1",size:'s1', month:'m1'],
[date:'d2',size:'s2', month:'m2'],
[date:'d3',size:'s3', month:'m3']]
render(view:'/index',
model:[data:data])
}
in gsp page:
<table>
<g:each in="${data}">
<tr><td>Date: ${it.date}, Size: ${it.size}, Month: ${it.month}</td></tr>
</g:each>
</table>
HTML view:
Date: d1, Size: s1, Month: m1
Date: d2, Size: s2, Month: m2
Date: d3, Size: s3, Month: m3
use <g:each> tag. Your <table> tag should be outside <g:each> and <tr> tags inside <g:each>
精彩评论