我需要显示在ec2上运行的服务器信息。我设法将它们显示为json,但现在我只需要显示某些字段。以下显示我如何显示statusCode
和RunType
。类似的概念适用于其他领域。如何在grails的这种情况下使用map?
def check = reservations.each { Reservation reservation ->
reservation.instances.each() { Instance instance ->
def code = instance.state
def StatusCode = code.code
//Get other values
instance.tags.each() { Tag tag5 ->
def KeyName2 = tag5.key;
if (KeyName2 == 'RunType') {
def RunType = tag5.value;
}
}
}
instance.tags.each() { Tag tag2 ->
def KeyName2 = tag2.key;
if (KeyName2 == 'RunType') {
def value2 = tag2.value; }
}
instance.tags.each() { Tag tag3 ->
def KeyName3 = tag3.key;
if (KeyName3 == 'StartedBy') {
def value = tag3.value;
}
}
我想获得这样的事情对每个服务器在我的GSP页面,并循环播放显示。
def map = [StatusCode:"80", RunType:"Always", value"test", value2:"abc"]
,但不知道如何添加值当我得到他们直通代码
您可以编辑您的问题补充那种你所期望得到的地图是形状后更新? –
那么,你想要一个地图列表?这很难看到你有什么,你想要什么... –
是的,我想你必须最终使用地图列表。请参阅下面的答案。 – dmahapatro