This is the code I will used, I have tested and it work.
main.gsp
<body>
<div id="grailsLogo" role="banner"><a href="http://grails.org"><img src="${resource(dir: 'images', file: 'grails_logo.png')}" alt="Grails"/></a></div>
<div>
<g:if test="${flash.message }">
${flash.message }
</g:if>
</div>
<g:layoutBody/>
<div class="footer" role="contentinfo"></div>
<div id="spinner" class="spinner" style="display:none;"><g:message code="spinner.alt" default="Loading…"/></div>
<r:layoutResources />
</body>
Controller:
package com.mtsinai
class EmployeeController {
def index() {
flash.message = 'Welcome world'
}
}
index.gsp
<%@ page contentType="text/html;charset=UTF-8" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
<meta name="layout" content="main"/>
<title>Insert title here</title>
</head>
<body>
<div class="body">
</div>
</body>
</html>
Note that the flash message will be displayed on top of the body or the page that will be rendered