how can i render to the gsp view of other controller?

后端 未结 3 1799
别那么骄傲
别那么骄傲 2021-02-08 22:40

I m new to grails,just started with a small application,

I\'m searching a solution for below problem,

Can any one tell me how can i render to GSP view page of ot

3条回答
  •  长发绾君心
    2021-02-08 23:29

    Lets suppose you want to render finalView.gsp of FirstController from normalView.gsp of SecondController having the following structure :

    FirstController.groovy
       finalView.gsp
    SecondController.groovy
       normalView.gsp
    

    normalView.gsp will have :

    Redirect to finalView.gsp 
    

    Then inside your SecondController, define one action called redirectToFirstController

    def redirectToFirstController =  {
     redirect(controller:"FirstController",action:"renderFinalView")
    }
    

    And inside your FirstController:

    def renderFinalView = {
    render(view:"finalView");
    }
    

提交回复
热议问题