gpt4 book ai didi

grails - 试图在3.1.10下使用g include标签

转载 作者:行者123 更新时间:2023-12-02 15:48:47 26 4
gpt4 key购买 nike

尝试在grails 3.1.10应用程序上使用g:include,看来:
这似乎通过确定传递ID

<g:include action="show" id="${currentBook.id}" />
试图通过参数传递(似乎没有通过):
<g:include action="list" params="[sort: 'title', order: 'asc',
author: currentBook.author]" />
只是想知道这是否是在更高版本中修复的错误的形式,如果是,哪个版本?
嗯,在以后的版本中也可能是一个错误,我的参数有一个点
 <g:include action="list" params="['sort.id': 'title']" />
当我尝试使用.something时,它不会返回任何参数
e2a
我可以确认它是在grails 3.27下发生的,我将提交一个错误:
假设我们有一个像这样的 Controller :
类TestController {
def index() { }

def test1() {
println "params are $params"
render params
}
def test2() {
println "params are $params"
render params
}
}
和一个gsp索引页面:
   <html>
<head>
<meta name="layout" content="main"/>
</head>


<g:include action="test1" params="${[id:1L]}"/>
<g:include action="test1" params="[id:2L]"/>
----<br>
<g:include action="test2" params="${['field.id':3L]}"/>
<g:include action="test2" params="['field.id':4L]"/>
<g:include action="test2" params="[fieldId:5L]"/>
<g:include action="test2" params="${['fieldId':6L]}"/>
如下所示,它们是field.id的 3L4L似乎没有出现在上述 Controller 操作的println或render语句中
调试printlns
 params are [id:1, action:test1, format:null, controller:test]
params are [id:2, action:test1, format:null, controller:test]
params are [action:test2, format:null, controller:test]
params are [action:test2, format:null, controller:test]
params are [fieldId:5, action:test2, format:null, controller:test]
params are [fieldId:6, action:test2, format:null, controller:test]
来自 Controller 的HTML输出:
['id':'1', 'action':'test1', 'format':null, 'controller':'test'] 
['id':'2', 'action':'test1', 'format':null, 'controller':'test'] ----

['action':'test2', 'format':null, 'controller':'test']
['action':'test2', 'format':null, 'controller':'test']
['fieldId':'5', 'action':'test2', 'format':null, 'controller':'test']
['fieldId':'6', 'action':'test2', 'format':null, 'controller':'test']

最佳答案

我没有在grails 3中尝试过,但是在grails 2中,您必须在您的情况下将params值放入${}params="${['sort.id': 'title']}"

关于grails - 试图在3.1.10下使用g include标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42866821/

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