如何在GSP页面以不同风格显示不同的flash.message [英] How to display different flash.message in different style in GSP page

查看:123
本文介绍了如何在GSP页面以不同风格显示不同的flash.message的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have to display different messages using flash.message, some of them have to be in different color, So How to distinguish the flash.message and display them in different color in GSP

推荐答案

查看页面代码以查看错误并在不同样式中添加消息

the view page code to view error and suces msg in different style

   <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:


the controller code to call respective label 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)

如果错误:

if error:

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)

这篇关于如何在GSP页面以不同风格显示不同的flash.message的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆