【问题标题】:grails how do I call one controllers action and embed the resulting view in another controllergrails我如何调用一个控制器动作并将结果视图嵌入另一个控制器
【发布时间】:2015-04-30 10:55:26
【问题描述】:

假设我有控制器 AuthorBook 像这样:

class Author{
 def show(Integer authorId){
     //code
  render view:'show',model:[author:author]
 }
}

class Book{
 def list(Integer authorId){
 //code
 render view:'list', model:[books:books]
}
}

现在,当渲染作者的显示页面时,我想显示作者写的书籍列表,我想通过传递 authorId 调用 Book 的控制器列表操作来实现。

有可能吗?如果是怎么办?

【问题讨论】:

    标签: grails sitemesh


    【解决方案1】:

    简单

    作者show.gsp 中这样做:

    <g:include controller = "book" action="list" id="${authorInstance?.id}" />
    

    For detail here

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-09-06
      • 1970-01-01
      • 2015-03-12
      相关资源
      最近更新 更多