简体   繁体   English

创建带有参数的网址,并将其用于其他gsp页面grails groovy

[英]creating a url with params, and using them in other gsp page grails groovy

I would like to dynamically create a link with some parameters to a page where those values would be used: 我想动态地创建一个带有一些参数的链接,该参数指向将使用这些值的页面:

<td><a href="${createLink(controller:'display', action="viewer", params: ['file' : '${stream.file}', 'media' : '${stream.media}'])}">${fieldValue(bean: streamInstance, field: "media")}</a></td>

In my viewer.gsp I want to be use those values in a link that displays a video stream: 在我的viewer.gsp我想在显示视频流的链接中使用这些值:

<source src="path/to/my/videodir/${media}" type='video/mp4'></source>

But I'm not having much success so far :-(. Could someone please help me on that? 但到目前为止,我没有取得太大的成功:-(。有人可以帮我吗?

i see a few places where there should be semicolons instead of equals, and single quotes instead of double quotes 我看到一些地方应该有分号而不是等号,以及单引号而不是双引号

${createLink(controller:'display', action:'viewer', params:'[file : "${stream.file}", media : "${stream.media}']")}

my only other thoughts is that if the stream.file variables don't display their value, then try escaping the double quotes /" and if that doesn't work then try removing the ${} around stream.file and stream.media since they are already inside an EL block 我唯一的其他想法是,如果stream.file变量未显示其值,则尝试转义双引号/“,如果不起作用,则尝试删除stream.file和stream.media周围的$ {},因为他们已经在EL模块里面

This worked for me... 这对我有用...

<g:set var="myarray" value="[file: stream.file, media: stream.media]" />
<a href="${createLink(controller:'display', action:'viewer', params:myarray)}">
  ${fieldValue(bean: streamInstance, field: "media")}
</a>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM