【发布时间】:2015-04-18 04:12:02
【问题描述】:
我在我的控制器中设置了以下标头,代码如下
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: GET, POST');
header("Access-Control-Allow-Headers: X-Requested-With, Content-Type");
如何在 zend 框架 2 中实现这一点,
谢谢
【问题讨论】:
-
我已经按照以下方式完成了,我是对的:$resp->getHeaders()->addHeaders(array('Content-Type' = > 'application/x-www-form-urlencoded ; charset=UTF-8' 'Allow-Methods' = > 'GET, POST' 'Allow-Origin' = > '*' ));
-
感谢 foozy,这有助于设置其他标头,例如 Cache-Control、Pragma 和 Expires
标签: php rest zend-framework2 http-headers httprequest