Grails渲染模板不同的控制器/路径 [英] Grails Render Template Different Controller/Path
问题描述
我有一个存在于views / dashboard / _myTemplate.gsp和DashboardController下面的模板,我可以直接调用
render模板:'myTemplate'
一切都很好。我需要从不同的控制器渲染此模板,但渲染方法不允许您指定控制器,我似乎无法弄清楚如何定义模板存在的路径以使渲染正常工作。这是可能的吗?
您可以通过控制器名称来执行此操作:
< pre $ render(template:'/ dashboard / myTemplate')
I have a template that exists under views/dashboard/_myTemplate.gsp and from the DashboardController I can simply call
render template:'myTemplate'
and all is well. I have a need to render this template from a different controller but the render method doesn't allow you to specify a controller and I can't seem to figure out how to define the path at which the template exists for the render to work correctly. Is this even possible?
You do it by controller name:
render(template:'/dashboard/myTemplate')
这篇关于Grails渲染模板不同的控制器/路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!