代码之家  ›  专栏  ›  技术社区  ›  Trainee

如何获得表演。并将其传递给另一个控制器

  •  0
  • Trainee  · 技术社区  · 8 年前

    Get(param.id) in Controller.show()

    这里有一个问题,我如何能够捕获所选(show.gsp)的参数(例如:taskName),并将其“发送”给另一个控制器。

    我已经想出了如何捕捉

    def taskName = Task.get(params.id)

    我可以知道如何发送taskName吗

    1 回复  |  直到 8 年前
        1
  •  0
  •   Nitin Dhomse    8 年前

    以下其中一项应该适合您,

         def show(){
                     def taskName = Task.get(params.id)
                    //Using redirect
                     redirect(controller: "AnotherController", action: "ActionInAnotherController", params: [taskName:taskName])
    
                    //OR using forward
    
                    def model = [
                        taskName : taskNme, 
                    ]
    
                    forward(controller:"AnotherController",action:"ActionInAnotherController", model:model)
    
                    //OR using chain
                    chain(controller:'AnotherController',action:'ActionInAnotherController ',model:model)
    
                 //Redirect to another domain controller
                   redirect(url: "anotherDomainUrl/AnotherController/ActionInAnotherController", params: [taskName:taskName])
    
     }
    
    推荐文章