yii2过滤器(filter)

一、VerbFilter

VerbFilter检查请求动作的HTTP请求方式是否允许执行

如果不允许,会抛出HTTP 405异常

use yii\filters\VerbFilter;
public function behaviors()
{
    return [
        'verbs'=>[
            'class' => VerbFilter::className(), //类名
            'actions'=>[ //方法
                'index' => ['get'], //index方法只能用get请求,如果用post等就会报405
            ],
        ],
    ];
}

`

猜你喜欢

转载自www.cnblogs.com/chrdai/p/9049283.html
今日推荐