3
précédemment j'utilise Spring MVC et l'annotation @ModelAttribute.Comment définir l'attribut de modèle pour chaque action
@Controller
public class ArticleController {
@ModelAttribute("articles")
public List<Testset> getArticles(){
return articleDao.all();
}
@RequestMapping("/first.htm")
public void first(){
}
}
Comment peut-on faire ce comportement dans le contrôleur Grails?
class ArticleController{
//this variable I want to in every action
List articles
def first = { }
def second = { }
def third = { }
}
Bien sûr, je peux utiliser ce code pour chaque action
def first = {
this.articles = Article.all()
}
mais je veux pas.
Merci beaucoup pour votre aide. Tomáš