grailsgsp

how to use the groovy controller element in JavaScript


I have

def exception = request.exception.stackTraceLines

in Groovy controller. How can I get the value of the exception in the JavaScript.


Solution

  • If you are adding exception to your return like this.

    flash.message = message(exception: 'Error: xxx');
    

    you can get it like this

    <div class="message" role="status"> ${flash.message} </div>
    

    just use ${ your flash.your_var_name}