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

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

问题描述

我需要的ID值传递给我的控制器执行的操作。目前,这是我在我的控制器。

  DEF startserver的(){
    amazonWebService.ec2.startInstances(新StartInstancesRequest([InstanceToStart]))
    重定向操作:指数()
    }

InstanceToStart 价值将来自视图。在我看来,我有一个表与下面的列,Id和按钮:

  I-333dced<按钮和GT;
I-dhdhdhd<按钮和GT;
I-er32ws<按钮和GT;

当我preSS我想要的标识传递,然后执行我的行动按钮。我的按钮code是如下:

 < G:链接动作=startserver的>
  <输入类型=按钮值=启动服务器级=stopimgID =startserver的/>
  < / G:链接>


解决方案

这是根据您的需要使用上面的人。我敢打赌,你也将获得样本/问题/答案在这里因此与相同的需求,如果你搜索。

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()
    }

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>

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>

解决方案

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天全站免登陆