在我看来,我这样调用操作方法:
<form class="my_form" action="${portletResponse.createActionURL()}" method='post'>
.....
<g:actionSubmit value="Save"/>
这将我带到我的操作方法:
def actionView = {
//.... do stuff
}
但是,我想在 View 中添加更多按钮来调用不同的操作方法。一个 Action 可能会删除一个对象中的一行数据。另一个可能会在另一个对象中创建一行数据。所以我的问题是,为什么createActionURL()会在 Controller 中调用actionView方法,以及如何为不同类型的操作实现多个操作方法?
谢谢!
最佳答案
...and how can I implement multiple action methods for different types of actions?
您应该使用
<g:form...
和<g:actionSubmit...
标签。表单中可以有任意多个提交按钮。有关更多信息,请参见http://docs.grails.org/3.2.4/ref/Tags/actionSubmit.html。
关于grails - 多种 Action 方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41348499/