I am getting problem in adding the named argument and map in the same params attribute in g:link. I can put named argument such as:
<g:link action="action" controller="controller" params='[hello:"hello",world:"world"]'>test</g:link>
or I can make the map in the controller and use that in gsp link params such as:
<g:link action="action" controller="controller" params='${testParam}'>test</g:link>
This both form the link in proper manner. But now i want to use both ways in the same link inside params attribute such as:
<g:link action="action" controller="controller" params='${testMapParam},[hello:"hello",world:"world"]'>test</g:link>
I am unable to do in this way. This don't make the proper link. Is there a way to do this? Please help me in this.
Thanks in advanced, Cheers!!!
答案 0 :(得分:1)
有时你真的不能轻视:
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>
点击链接时显示此信息 {a = 1} {hello1 = hello2,world1 = world2} test
点击后我的网址是:
/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]
你想做什么?没有