I used to use Spring MVC and the @ModelAttribute annotation.
@Controller
public class ArticleController {
@ModelAttribute("articles")
public List<Testset> getArticles(){
return articleDao.all();
}
@RequestMapping("/first.htm")
public void first(){
}
}
How can this be done in the Grails controller?
class ArticleController{
//this variable I want to in every action
List articles
def first = { }
def second = { }
def third = { }
}
Of course, I can use this code for every action.
def first = {
this.articles = Article.all()
}
but I do not want this.
Many thanks for your help. Tomash
source
share