How to pass values from view to controller in grai

2019-01-29 09:09发布

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>

1条回答
一纸荒年 Trace。
2楼-- · 2019-01-29 09:44

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.

查看更多
登录 后发表回答