2017-02-20 16:06:33 4723次浏览 2条评论 1 0 0

在Controller里重写behaviors方法,方法体为:

$behaviors = parent::behaviors();
$behaviors['contentNegotiator']['formats'] = '';
$behaviors['contentNegotiator']['formats']['application/json'] = Response::FORMAT_JSON;
return $behaviors;

提醒:formats先设为空,不然无效

您需要登录后才可以评论。登录 | 立即注册