如何使用Grails中的字段插件渲染

发布于 2025-02-11 17:58:43 字数 1039 浏览 0 评论 0原文

我的代码:

hotelcontroller:

def search() {
    def result = Hotel.list()
    render(template: "searchTable", model: [hotelList: result], plugin: "fields")
}

views目录:

​https://i.sstatic.net/qhikv.png“ alt =”在此处输入图像描述“>

错误消息:

URI
/hotel/search
Class
org.grails.web.servlet.mvc.exceptions.ControllerExecutionException
Message
null
Caused by
Unable to load template for uri [/hotel/_searchTable]. Template not found.

Around line 24 of grails-app\controllers\com\pool\HotelController.groovy
24:        render(template: "searchTable", model: [hotelList: result], plugin: "fields")

不应该这样:因为字段插件搜索/_ fields 目录

如果我尝试放置_searchtable.gsp /hotel目录中的模板 - 渲染方法像往常一样呈现< g:render>标签

编译:org.gerails.plugins:fields在build.gradle中

My code:

HotelController:

def search() {
    def result = Hotel.list()
    render(template: "searchTable", model: [hotelList: result], plugin: "fields")
}

views directory:

enter image description here

templates directory:

enter image description here

Error message:

URI
/hotel/search
Class
org.grails.web.servlet.mvc.exceptions.ControllerExecutionException
Message
null
Caused by
Unable to load template for uri [/hotel/_searchTable]. Template not found.

Around line 24 of grails-app\controllers\com\pool\HotelController.groovy
24:        render(template: "searchTable", model: [hotelList: result], plugin: "fields")

Should not be like that because fields plugin searches templates in /templates/_fields directory

If I try to place _searchTable.gsp template in /hotel directory - render method renders it as usual <g:render> tag

compile: org.gerails.plugins:fields is in build.gradle of course

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文