2012-10-10 48 views
0

我必须使用flash.message显示不同的消息,它们中的一些必须以不同的颜色显示,那么如何区分flash.message并将它们显示为不同的颜色颜色GSP如何在GSP页面以不同风格显示不同的flash.message

+3

如何在闪存范围内使用不同的变量?例如。 flash.errorMessage,flash.successMessage等 –

+0

perfecto,是的 – n92

回答

3

查看页面代码在不同的风格来查看错误和suces味精

<g:if test="${flash.message}"> 
     <div class="message" role="status" style="font-size: medium;color: green;">${flash.message}</div> 
    </g:if> 
    <g:if test="${flash.warning}"> 
     <div class="message_error" style="font-size: medium;color: red;">${flash.warning}</div> 
    </g:if> 

控制器代码来调用相应的标签 如果scues:

flash.message = message(code: 'Applied Successfully', args: [message(code: 'hrIrRegistration.label', default: 'HrIrRegistration'), hrIrAplcJobAppldLkInstance.id]) 
       redirect(controller: "hrIrRegistration", action: "showVcnyForApplcnt", id: params.hrIrVcncyIdHrIrVcncy.id) 

如果错误:

flash.warning = message(code: 'You have already Applied in this vacancy', args: [message(code: 'hrIrRegistration.label', default: 'HrIrRegistration'), hrIrAplcJobAppldLkInstance.id]) 
       redirect(controller: "hrIrRegistration", action: "showVcnyForApplcnt", id: params.hrIrVcncyIdHrIrVcncy.id) 
相关问题