0
我试图使用邮递员yii2前端张贴,但我得到这个Yii2交法不允许
{
"name": "Method Not Allowed",
"message": "Method Not Allowed. This url can only handle the following request methods: GET, HEAD.",
"code": 0,
"status": 405,
"type": "yii\\web\\MethodNotAllowedHttpException"
}
我不知道如何从前端张贴。
这是我的前端控制器代码
class TestController extends ActiveController {
public $modelClass = 'common\models\Test';
public function behaviors(){
$behaviors = parent::behaviors();
$behaviors['corsFilter'] = [
'class' => \yii\filters\Cors::className(),
'cors' => [
'Origin' => ['*'],
'Access-Control-Expose-Headers' => ['X-Pagination-Current-Page', 'X-Pagination-Page-Count'],
],
];
return $behaviors;
}
public function actions(){
$actions = parent::actions();
unset($actions['index']);
return $actions;
}
public function actionIndex(){
$activeData = new ActiveDataProvider([
'query' => Test::find()->orderBy('test_id DESC'),
'pagination' => [
'defaultPageSize' => 5,
]
]);
return $activeData;
}
}
我是相当新的编程,需要对如何让POST方法一个非常简单的说明和示例。
http://localhost/advanced/frontend/web/index.php?r=test