我正在返回一个包含多个项目的地图值。地图如下:
def myList = []
//Some code to obtain the List
List << ["Id": Id,"Name": Name,"Code": sCode, "RunType": x ]
return [items: List]
在我的 GSP 页面中,我使用以下代码将它们打印到我的网页中。
<%
def counter = 0
for (i in items) {
counter = counter + 1
println("<td>" + i + "</td>" + "\n")
if (counter == 1) {
println("</tr><tr>")
counter = 0
}
}
%>
输出如下所示:
[Id:i-d0f5, Name:es_test_1b_110.test.com, Code:16, RunType:On Demand]
[Id:i-7890, Name:namc-qc.test.com, Code:16, RunType:On Demand]
[Id:i-ee56, Name:abcdef.test.com, Code:16, RunType:On Demand]
[Id:i-c41e, Name:backup.grails.test.com, Code:80, RunType:On Demand]
我现在需要为每个打印的值添加一个按钮(因此,如果打印了 6 个服务器,则会显示 6 个按钮,如果打印了 10 个服务器,则会显示 10 个按钮)我将使用该按钮将 ID 传递给启动和停止服务器。