无法使用Code Igniter、REST、Lighttpd url rewrite和Backbone.js接收PUT数



我将CodeIgniter与REST API和Backbone.js一起使用。Web服务器是lighttpd。我还修改了lighttpd.conf,以便重写URL,从URL中删除index.php,如下所示:-

url.rewrite-once = (
 "/(.*).(.*)" => "$0",
 "/(css|files|img|js|stats)/" => "$0",
 "^/([^.]+)$" => "/index.php/$1"
)

js的调用到达Codeigniter Put函数,但$this->Put()的值为空。请帮我找出PUT数据值为空的原因。

注意:当我不重写URL时,这非常好用。这也适用于Apache web服务器。

在调试REST_Controller.php文件时,在函数"protected function _parse_put()"中,我发现文件"php://input"也是空的

以下是在进行PUT调用时从Chrome Web检查器获取的请求标头和有效负载:-

**Request Headers**
PUT http://10.82.0.160/cav_settings/api/2 HTTP/1.1
Pragma: no-cache
Origin: http://10.82.0.160
Cache-Control: no-cache
User-Agent: Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.56 Safari/537.17
Content-Type: application/json
Accept: application/json, text/javascript, */*; q=0.01
Referer: http://10.82.0.160/settings/2
X-Requested-With: XMLHttpRequest
**Request Payload**
{"aggregation":{"enabled":"false","mode":""},"dns":{"auto":"false","servers":["10.0.0.5","10.20.0.20"]},"id":"2","dhcp":"false","ip":"10.82.0.160","netmask":"255.255.255.0","default_gw":"","mtu":"1500"}

您可以使用Backbone.mulateJSON=true;

这是解决您疑问的最佳答案:)

Codeigniter REST服务器的Backbone.js PUT/DELETE问题

相关内容

  • 没有找到相关文章

最新更新