我可以在GSP外使用grails标签吗? [英] Can I use grails tag outside of GSP?

查看:185
本文介绍了我可以在GSP外使用grails标签吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

例如,我可以将

 < g:createLink controller =useraction =show/> ; 

在.gsp文件中,它会正常工作。



但是我想在.groovy文件里面使用不是grails视图的一部分的相同的闭包 createLink

$ b $您可以使用Grails控制器的taglib方法,例如:

 <$> 

c $ c> def userShow = g.createLink(controller:user,action:show)

对于内置taglib(或g命名空间中的那些),您可以省略方法调用中的命名空间前缀。


For example, i can put

 <g:createLink controller="user" action="show" /> 

inside a .gsp file and it will work nicely.

But also I'd like to use the same closure createLink inside a .groovy file which is not part of the grails views

解决方案

You can use taglib methods from Grails controllers, for example:

def userShow = g.createLink(controller:"user", action:"show")

For builtin taglibs (or those in the g namespace) you can omit the namespace prefix in the method call.

这篇关于我可以在GSP外使用grails标签吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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