假设我有一个带有链接的gsp文件正在使用标签“阅读更多。此链接将打开另一个gsp文件名” blog”,如果您查看网址栏,您会看到我当前的链接为“MyWebApp / post /博客/(当前i值)。那么,如何从新的blog.gsp文件中获取(当前i值)实际上是一个整数?
最佳答案
class PostController {
def list() {
// this action calls the page that has the "Read more" link
def posts = Post.list()
[posts: posts]
}
def blog() {
// this action is triggered by the "Read more" link and
// renders your blog post where you want the current ID
def post = Post.get(params.id)
[post: post]
}
}
blog.gsp
<html>
....
${post.id}
....
</html>
关于grails - 如何通过从gsp文件到grails中的另一个gsp文件的链接获取传递的 “id”参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16743878/