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