Grails controllers repeated code for all actions
问题 Imagine this controller: class exampleController{ def action1 = {} def action2 = {} def action3 = {} def action4 = {} def action5 = {} } I want to be able to return in all the action in this controller the same params. Imagining this: def user = session.user [user: user] Is there any way of doing this, besides writing all the same code on all the actions? The session.user return params is just an example. I don't wanna really return it. 回答1: A simple solution is to put this code in a method