我知道我可以在UrlMappings.groovy中使用"/"(controller: "default")
为根页面指定一个 Controller ,但是我想使我的主布局页面(在这种情况下为main.gsp)访问至少一个定义的 Controller 。我已经尝试过"/layouts/main.gsp"(controller: "default")
,但是没有用。我该怎么做?谢谢!
最佳答案
main.gsp
是布局,而不是页面。布局由 Controller 呈现的页面使用。您不应具有使 Controller 呈现布局的设计。它破坏了Grails的美丽结构。如果要访问该布局中的对象,则可以将该对象传递给使用该布局的页面。告诉我们您的用例,我们也许可以为您提供更多帮助。
关于grails - 为main.gsp布局指定一个 Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12240843/