gpt4 book ai didi

grails - 从taglib获取访问 Controller

转载 作者:行者123 更新时间:2023-12-02 13:50:07 25 4
gpt4 key购买 nike

是否可以从TagLib中访问当前 Controller 实例?例如:

class FooTagLib {
static namespace = 'foo'

def msg = { attrs, body ->
// Can I get a reference to the current controller here?
}
}

我想这样做是因为我将一些数据存储在 Controller 的属性中,并希望在TagLib中访问它。我意识到这听起来可能很奇怪,但我很幽默。

最佳答案

在您的味精tagLib中:

grailsApplication.getArtefactByLogicalPropertyName('Controller', pageScope.controllerName)

与 View 一样,您可以通过 controllerNameactionName访问当前 Controller 和操作

关于grails - 从taglib获取访问 Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5462552/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com