Parses a raw HTTP request using yii\helpers\Json::decode()
To enable parsing for JSON requests you can configure yii\web\Request::$parsers using this class:
'request' => [
'parsers' => [
'application/json' => 'yii\web\JsonParser',
]
]
1、将以上配置添加到main.php 中的 components数组里面
2、用postman模拟
header头传参数: Content-Type: application/json
然后选择raw类型的json格式,传入内容:{"name":"abc"}
3、在服务器端正常的接受post,输出查看结果是否正常