【发布时间】:2014-02-17 05:34:57
【问题描述】:
我正在从 zend 控制器返回 Json 响应。
这是我的代码
控制器代码
public function get()
{
$result = //calling other function and getting response in array
print("value in controller before calling toJsonModel");
print_r($result);
$temp = $this->toJsonModel($result);
var_dump($temp);
return $temp;
}
toJsonModel函数
public function toJsonModel($data = array())
{
$data['requestId'] = $this->getHeader('RequestId');
print("Value just before returning to controller");
print_r($data);
return new JsonModel($data);
}
回应
第一次和第二次打印显示正确的值。但是在从 toJsonModel 获取值之后,当我尝试显示错误的值并添加一些其他值(如“captureTo”、“terminate”和“children”)作为受保护时。
我不知道为什么它给了我错误的信息。
谁能指导我正确的道路并告诉我问题是什么?
提前致谢。
编辑 我正在添加新的屏幕截图以显示完整的消息。
错误:
{"name":"Email Not Found","message":"找不到使用此电子邮件的帐户 地址。","code":404,"requestId":"12","reason":"error-controller-cannot-dispatch","display_exceptions":true,"controller":"RSMobile\Controller\ForgotPassword", "controller_class":null}
【问题讨论】:
-
到底出了什么问题?
-
我收到“调度错误”。看截图。
标签: php json zend-framework zend-framework2