我在删除所有表格中的记录时收到错误:
# EACCESS error reference: https://docs.npmjs.com/getting-started/fixing-npm-permissions
# Install Homebrew # Reference: brew.sh # Ensures NPM is installed properly to avoid EACCESS errors
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
# Install npm # Reference: brew.sh
brew install node
# Install firebase-tools
npm install -g firebase-tools # Non-recurring task # Also updates to newest version (see notice)
An Error occurred while handling another error:
exception 'yii\web\ForbiddenHttpException' with message 'You are not allowed to perform this action.' in D:\FORBIDDEN\projects\UniServerZ\www\project\vendor\yiisoft\yii2\filters\AccessControl.php:151
Stack trace:
_
我的控制器:
Previous exception:
exception 'yii\web\MethodNotAllowedHttpException' with message 'Method Not Allowed. This url can only handle the following request methods: POST.' in D:\FORBIDDEN\projects\UniServerZ\www\project\vendor\yiisoft\yii2\filters\VerbFilter.php:105
Stack trace:
public function behaviors()
{
return [
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'delete' => ['POST'],
],
],
];
}
以及view.php中的删除按钮
public function actionDelete($id)
{
$this->findModel($id)->delete();
return $this->redirect(['index']);
}
当我用GET替换POST时它的工作,但警报确认不起作用..
你知道什么是错的吗?请帮助
答案 0 :(得分:0)
public function behaviors()
{
return [
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'delete' => ['post'],//not POST
],
],
];
}
错误的错误,希望它会有所帮助
ref.link
http://www.yiiframework.com/doc-2.0/yii-filters-verbfilter.html
答案 1 :(得分:0)
可能是您收到错误消息
Method Not Allowed. This url can only handle the following request methods: POST.
因为某种程度上浏览器会重新加载带有请求网址的页面。当您单击链接以删除该模型时,请求方法是POST,因为它已指定。此时发生了一些异常(似乎与访问规则有关),这使得浏览器原谅了请求方法。