Grails渲染模板不同的控制器/路径 [英] Grails Render Template Different Controller/Path

查看:93
本文介绍了Grails渲染模板不同的控制器/路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个存在于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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆