论坛首页 Web前端技术论坛

HTML5的表单到底还是不支持PUT、DELETE?

浏览 4390 次
精华帖 (0) :: 良好帖 (5) :: 新手帖 (0) :: 隐藏帖 (0)
作者 正文
   发表时间:2010-06-06   最后修改:2010-06-06

      REST架构的核心属性之一便是统一接口,可现在的HTML表单只支持GET和POST方法,一下子就“禁掉”(但是还是可以通过JavaScript脚本实现其它接口)了REST要求的一半接口。《RESTful Web Services》中很多例子都给form的method赋上了PUT、DELETE值,说是HTML5中会支持。于是我就好奇地搜了下HTML5在这方面的内容。

 

      在w3.org上的HTML5仓库里看到了一篇《HTML5 differences from HTML4》,是今年三月10号发布的草案。简单的用Ctrl-F搜了下“ form ”关键字,好像并没有提到改进了method方法,form的属性改动不少,但就是没有method啊……于是就疑惑了,难道用PUT和DELETE还得写JS?

 

文章发布得冲动了……刚才翻看了最新的HTML5草案,看到了这段话:

The method and formmethod content attributes are enumerated attributes with the following keywords and states:

  • The keyword GET, mapping to the state GET, indicating the HTTP GET method.
  • The keyword POST, mapping to the state POST, indicating the HTTP POST method.
  • The keyword PUT, mapping to the state PUT, indicating the HTTP PUT method.
  • The keyword DELETE, mapping to the state DELETE, indicating the HTTP DELETE method.

The missing value default for these attributes is the GET state.

The method of an element is one of those four states. If the element is a submit button and has a formmethod attribute, then the element's methodis that attribute's state; otherwise, it is the form owner's method attribute's state.

为什么那篇differences就不提呢……

   发表时间:2010-06-10  
如果不能原生全面支持PUT/GET/POST/DELETE,对于REST来说果然有点小杯具
0 请登录后投票
   发表时间:2010-06-11  
  刚开始对rest不了解的时候,感觉有点兴奋,于是去研究了下它,我觉得使用rest太受限制了(struts2)。
比方如:我想要做一个下载,都不知道怎么去做了。就那么几个方法,每个方法对应的都有链接。
0 请登录后投票
   发表时间:2010-06-12  
grasszring 写道
  刚开始对rest不了解的时候,感觉有点兴奋,于是去研究了下它,我觉得使用rest太受限制了(struts2)。
比方如:我想要做一个下载,都不知道怎么去做了。就那么几个方法,每个方法对应的都有链接。


你说的是某些连接的4个方法都被占用了
但是既然是用RESTful的形式安排资源,那么附件如果有单独请求下载的需要,那么请给附件也抽象为一类资源,专门用于下载。
比如某篇文章的URL是HTTP://XXX.COM/ESSAY/1 方法为GET
这篇文章的其中某个附件下载地址应该为HTTP://XXX.COM/ATTACHMENT/1/XXX.ZIP 方法为GET

0 请登录后投票
论坛首页 Web前端技术版

跳转论坛:
Global site tag (gtag.js) - Google Analytics