forms - 如何从 HTML 表单调用 RESTful 服务?

标签 forms http rest grails post

我们正在使用 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/

相关文章:

forms - 防止重新提交表单

java - Struts 2,JasperReports 插件 : How to set file name for generated report

rest - Firebase REST API 使用电话号码进行身份验证

jQuery克隆和appendTo复制错误的内容

c# - Windows 窗体 : Treeview AfterClick event responding differently for Mouse Left and Mouse Right Click

java - 无需等待响应的 HTTP 请求

rest - 我在使用 GOPATH 和 Intellij idea 时遇到了麻烦

java - 具有许多长参数的永久 REST Web 服务 URL

javascript - 所见即所得提交表单

jQuery-Validation-Engine - 当值为空时,自定义 funcCall 验证会导致错误