如何在grails中将值从视图传递给控制器 [英] How to pass values from view to controller in grails

查看:25
本文介绍了如何在grails中将值从视图传递给控制器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要将 Id 值传递给我的控制器以执行操作.目前这是我的控制器中的内容.

I need to pass the Id value to my controller to execute the action. Currently this is what I have in my controller.

    def StartServer() {
    amazonWebService.ec2.startInstances(new StartInstancesRequest([InstanceToStart]))
    redirect action: index()
    }

InstanceToStart 值将来自视图.在我看来,我有一个包含以下列、Id 和按钮的表格:

The InstanceToStart value will come from the view. In my view I have a table with the following columns, Id and button:

i-333dced <Button>
i-dhdhdhd <Button>
i-er32ws  <Button>

当我按下按钮时,我希望传递 Id,然后执行我的操作.我的按钮代码如下:

When I press the button I want the Id to pass and then execute my action. My button code is as follows:

  <g:link action="StartServer">
  <input type="button" value="Start Server" class="stopimg" id="startServer"/>
  </g:link>

推荐答案

  • createLink
  • 远程链接
  • 远程功能
  • 根据您的需要使用上面的任何人.我敢打赌,如果您进行搜索,您也会在此处获得与相同要求相关的示例/问题/答案.

    Use anyone from above according to your need. I bet you will also get samples/questions/answers here in SO related to the same requirement if you search.

    这篇关于如何在grails中将值从视图传递给控制器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆