render('index'); } /** * 错误处理器 * @return string|\yii\web\Response */ public function actionError() { $handler = Yii::$app->getErrorHandler(); $exception = $handler->exception; if ($exception == null) { // 没有异常 $exception = new NotFoundHttpException(); } $response = Yii::$app->getResponse(); $response->setStatusCodeByException($exception); return $this->renderPartial('/site/error404.php'); } }