gpt4 book ai didi

templates - 如何使域对象(数据)随处可见? ils子

转载 作者:行者123 更新时间:2023-12-02 15:34:03 24 4
gpt4 key购买 nike

I want to know how to make a domain object or its data available across the system everywhere in grails?

Like sort of syntex do i need to use to make it happen. ATM my app's user object/instance is only available on one of my 3 templates not even any other view.

最佳答案

这些 View 可用的原因是您的controller is pushing the model to those views。没有什么阻止您从任何所需的 Controller /服务中使用域的。

例如,我可以执行以下操作:

class HomeController {

def index() {
def users = User.list()
render view: "list", model: [users: users]
}
}

请注意,我是如何完全脱离常规的,但仍然有效。

关于templates - 如何使域对象(数据)随处可见? ils子,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14448237/

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