Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
发布JSON后的代码500?_Json_Cakephp - Fatal编程技术网

发布JSON后的代码500?

发布JSON后的代码500?,json,cakephp,Json,Cakephp,我正在尝试使用Chrome的Postman发布JSON。JSON是{“email”:myself@gmail.com“}。当我发送不起作用并抛出异常代码时:500。 查看app/tmp/logs/error.log中的I发现了问题,但不知道如何解决 例外情况 2015-08-16 01:06:43 Error: [MissingViewException] View file "Users\json\show_post_json.ctp" is missing. Exception Attrib

我正在尝试使用Chrome的Postman发布JSON。JSON是
{“email”:myself@gmail.com“}
。当我发送不起作用并抛出异常代码时:500。 查看app/tmp/logs/error.log中的
I发现了问题,但不知道如何解决

例外情况

2015-08-16 01:06:43 Error: [MissingViewException] View file "Users\json\show_post_json.ctp" is missing.
Exception Attributes: array (
  'file' => 'Users\\json\\show_post_json.ctp',
)
Request URL: /PainelEscolar/users/showPostJson.json
Stack Trace:
#0 C:\xampp\htdocs\PainelEscolar\lib\Cake\View\JsonView.php(107): View->_getViewFileName(NULL)
#1 C:\xampp\htdocs\PainelEscolar\lib\Cake\Controller\Controller.php(960): JsonView->render(NULL, NULL)
#2 C:\xampp\htdocs\PainelEscolar\lib\Cake\Routing\Dispatcher.php(200): Controller->render()
#3 C:\xampp\htdocs\PainelEscolar\lib\Cake\Routing\Dispatcher.php(167): Dispatcher->_invoke(Object(UsersController), Object(CakeRequest))
#4 C:\xampp\htdocs\PainelEscolar\app\webroot\index.php(118): Dispatcher->dispatch(Object(CakeRequest), Object(CakeResponse))
#5 {main}
//URL: http://localhost/PainelEscolar/users/showPostJson.json
public function showPostJson(){              
            $data = $this->RequestHandler->addInputType('json', array('json_decode', true));
            echo $data["email"];            
        }
PHP函数

2015-08-16 01:06:43 Error: [MissingViewException] View file "Users\json\show_post_json.ctp" is missing.
Exception Attributes: array (
  'file' => 'Users\\json\\show_post_json.ctp',
)
Request URL: /PainelEscolar/users/showPostJson.json
Stack Trace:
#0 C:\xampp\htdocs\PainelEscolar\lib\Cake\View\JsonView.php(107): View->_getViewFileName(NULL)
#1 C:\xampp\htdocs\PainelEscolar\lib\Cake\Controller\Controller.php(960): JsonView->render(NULL, NULL)
#2 C:\xampp\htdocs\PainelEscolar\lib\Cake\Routing\Dispatcher.php(200): Controller->render()
#3 C:\xampp\htdocs\PainelEscolar\lib\Cake\Routing\Dispatcher.php(167): Dispatcher->_invoke(Object(UsersController), Object(CakeRequest))
#4 C:\xampp\htdocs\PainelEscolar\app\webroot\index.php(118): Dispatcher->dispatch(Object(CakeRequest), Object(CakeResponse))
#5 {main}
//URL: http://localhost/PainelEscolar/users/showPostJson.json
public function showPostJson(){              
            $data = $this->RequestHandler->addInputType('json', array('json_decode', true));
            echo $data["email"];            
        }

问题是,您的控制器认为
showPostJson
是一个视图,因此正在尝试查找要渲染的视图文件

由于您只是从它输出JSON,因此可以使用
$this->render(false)
-防止它尝试加载视图,并且您可能还希望使用:


回音后再返回。它将尝试加载该方法的模板。也可以尝试$this->render(false)-我已经有一段时间没有使用cakephpI了
$this->autoRender=false
$data
之前,并且工作正常。谢谢。太好了。我会给你写一个答案,不是说我不在手机上