CakePlugin::routes();
Router::setExtensions('json');
Router::parseExtensions('json');
routes.php但仍然當我調試我得到'html'的迴應。如何獲取請求處理程序響應類型='cakephp中的json?'
debug($this->RequestHandler->responseType());
請幫幫我。
這是錯誤顯示在控制檯--->
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>404 Not Found</title>
</head><body>
<h1>Not Found</h1>
<p>The requested URL /cities/index.json was not found on this server.</p>
</body></html>
那是哪裏調試statment?如果它在beforeFilter()中,因爲RequestHandler將響應類型設置爲在beforeFilter()之後運行的startup()回調中,所以預計將會使用「html」。還打開調試,以獲得實際的錯誤,而不是通用的404,也許一些錯誤是在RequestHandler :: startup()可以運行之前生成的。 – ADmad