List Out All Request Header

//in a controller
def showAllHeaders(){
    StringBuilder sb = new StringBuilder()
        sb.append(it).append(": ").append(request.getHeader(it))

Showing Message, Error Message, Additional Error Messages in GSP Using Flash

Inside a method in a controller you do:

flash.message = "The request ${camsRequest.getRequestReference()} has been released."
//or, and
flash.error = "Internal Error. Unable to release this request. If this problem persist, please contact the technical support."
//or, and
List<String> errorMessages = []
errorMessages.add("First additional error")
errorMessages.add("Second additional error")
flash.errorMessages = errorMessages

Inside a GSP view, you do:

<div id="message-container" class="container-fluid">
    <g:if test="${flash.message}">
        <div class="row">
            <div class="col-sm-12 alert alert-info">

    <g:if test="${flash.error}">
        <div class="row">
            <div class="col-sm-12 alert alert-danger">
                    <g:each var="errorMsg" in="${flash.errorMessages}">
        flash.message = null
        flash.error = null
        flash.errorMessages = null

Note that we added flash.message = null, flash.error = null, and flash.errorMessages = null to make sure those field are cleaned up. We do this because I something notice that these values in flash are not being clean after a response.

  • grails/goodies.txt
  • Last modified: 2018/10/19 15:50
  • by chongtin