這是我將使用的代碼,我已經過測試,它的工作。 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>
控制器:
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>
注意閃光燈消息將在機身頂部或頁面將顯示被渲染
添加布局,主頁a nd控制器代碼的問題。 – dmahapatro
實際上這些代碼太大而無法在此發佈。請告訴我是否有任何具體的細節,我可以給你。我將粘貼這部分代碼。 –
您不需要發佈整個文件,只需要發佈與您的問題有關的部分。 – lukelazarovic