I Have the following controller:-
class HostController {
def index() {
def customMap = ['key1':'value1','key2':'value2']
[customMap : customMap]
}
}
and the following gsp view:-
<html>
<head>
<meta name="layout" content="main">
<g:set var="entityName" value="${message(code: 'host.label', default: 'Host')}" />
<title><g:message code="default.list.label" args="[entityName]" /></title>
</head>
<body>
this is the custom map
<g:each in="${customMap.value}" var="custom">
${custom}
</g:each>
</body>
I am unable to print thae values of the map. Although I am able to print the keys using:
<g:each in="${customMap}" var="custom">
${custom.key}
</g:each>
I am not sure what is being missed here. Any help here is much appreciated.
Thanks, AMar
Change your gsp code to:
<g:each in="${customMap}" var="custom">
${custom.value}
</g:each>
You see, customMap
is a recognized object which you passed from the controller to the view, customMap.value
is not.