gsp link 将命名参数和映射放在同一个参数属性中
gsp link to put named parameters and map in the same params attribute
我在 g:link
的同一个参数属性中添加命名参数和映射时遇到问题。
我可以输入命名参数,例如:
<g:link action="action" controller="controller" params='[hello:"hello",world:"world"]'>test</g:link>
或者我可以在控制器中制作地图并在 gsp link 参数中使用它,例如:
<g:link action="action" controller="controller" params='${testParam}'>test</g:link>
这两者都以适当的方式构成了 link。但是现在我想在 params 属性中的同一个 link 中使用这两种方式,例如:
<g:link action="action" controller="controller" params='${testMapParam},[hello:"hello",world:"world"]'>test</g:link>
这个我做不到。这不是正确的 link。有办法吗?
有时候你真的无法战胜简单:
def test() {
def map1=['a':1]
def map2=['a2':2]
def map3=map1+map2
println "000 ${map3} vs ${params}"
render view:'test', model:[map1:map1,map2:map2]
}
正在将地图传递给视图 gsp:
<g:set var="map6" value="${[hello1:'hello2',world1:'world2'] }"/>
<g:set var="currentParams" value="${params}"/>
${map1 } ${map6}
<g:link action="test" controller="test" params="${map1+map6+map2+currentParams}">test</g:link>
当我点击 link 时显示这个
{a=1} {hello1=hello2, world1=world2} 测试
点击后我的 url 是:
/test?a=1&hello1=hello2&world1=world2&a2=2&hello=hello&world=world
000 [a:1, a2:2] vs [hello:hello, a:1, a2:2, world1:world2, hello1:hello2, world:world, action:test, controller:test]
你想做什么?没有
我在 g:link
的同一个参数属性中添加命名参数和映射时遇到问题。
我可以输入命名参数,例如:
<g:link action="action" controller="controller" params='[hello:"hello",world:"world"]'>test</g:link>
或者我可以在控制器中制作地图并在 gsp link 参数中使用它,例如:
<g:link action="action" controller="controller" params='${testParam}'>test</g:link>
这两者都以适当的方式构成了 link。但是现在我想在 params 属性中的同一个 link 中使用这两种方式,例如:
<g:link action="action" controller="controller" params='${testMapParam},[hello:"hello",world:"world"]'>test</g:link>
这个我做不到。这不是正确的 link。有办法吗?
有时候你真的无法战胜简单:
def test() {
def map1=['a':1]
def map2=['a2':2]
def map3=map1+map2
println "000 ${map3} vs ${params}"
render view:'test', model:[map1:map1,map2:map2]
}
正在将地图传递给视图 gsp:
<g:set var="map6" value="${[hello1:'hello2',world1:'world2'] }"/>
<g:set var="currentParams" value="${params}"/>
${map1 } ${map6}
<g:link action="test" controller="test" params="${map1+map6+map2+currentParams}">test</g:link>
当我点击 link 时显示这个 {a=1} {hello1=hello2, world1=world2} 测试
点击后我的 url 是:
/test?a=1&hello1=hello2&world1=world2&a2=2&hello=hello&world=world
000 [a:1, a2:2] vs [hello:hello, a:1, a2:2, world1:world2, hello1:hello2, world:world, action:test, controller:test]
你想做什么?没有