我们正在使用 Grails 构建 RESTful 服务,我们将使用 HTML 表单从浏览器客户端调用这些服务,问题是表单仅支持 GET 和 POST,因此我们不确定如何处理 PUT 和 DELETE。
最佳答案
Grails 模板标签可以帮助您:
However, issuing a request with a method other than GET or POST from a regular browser is not possible without some help from Grails. When defining a form you can specify an alternative method such as DELETE:
<g:form controller="book" method="DELETE">
..
</g:form>
Grails will send a hidden parameter called _method, which will be used as the request's HTTP method. Another alternative for changing the method for non-browser clients is to use the X-HTTP-Method-Override to specify the alternative method name.
通过:http://www.grails.org/doc/latest/guide/13.%20Web%20Services.html
关于forms - 如何从 HTML 表单调用 RESTful 服务?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6997656/