佈局

2014-01-06 20 views
1

丟失閃存消息內容這是情景:
我有佈局:main.gsp
和對應用此佈局的頁面:homepage.gsp
我在哪裏main.gsp一個div如果有的話,我會顯示Flash消息。
佈局

現在,
當控制器發出任何提示信息,其在homepage.gsp可用,但在應用上的佈局和顯示頁面,提示信息會丟失。

我想要在佈局代碼中使用Flash消息。 同樣,如果我不需要向homepage.gsp添加任何代碼,因爲有許多控制器可以返回Flash消息的這樣的頁面,將會更好。

我該如何處理?
非常感謝任何幫助。

+1

添加布局,主頁a nd控制器代碼的問題。 – dmahapatro

+0

實際上這些代碼太大而無法在此發佈。請告訴我是否有任何具體的細節,我可以給你。我將粘貼這部分代碼。 –

+0

您不需要發佈整個文件,只需要發佈與您的問題有關的部分。 – lukelazarovic

回答

0

這是我將使用的代碼,我已經過測試,它的工作。 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&hellip;"/></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> 

注意閃光燈消息將在機身頂部或頁面將顯示被渲染