我正在尝试找出如何在路由未找到时显示404页面未找到。我遵循了许多教程,但它不起作用。
我在\laravel\resources\views\errors
中有404.blade.php
文件。
同时,在handler.php
中也有相关内容。
public function render($request, Exception $e)
{
if ($e instanceof TokenMismatchException) {
// redirect to form an example of how i handle mine
return redirect($request->fullUrl())->with(
'csrf_error',
"Opps! Seems you couldn't submit form for a longtime. Please try again"
);
}
/*if ($e instanceof CustomException) {
return response()->view('errors.404', [], 500);
}*/
if ($e instanceof \Symfony\Component\HttpKernel\Exception\NotFoundHttpException)
return response(view('error.404'), 404);
return parent::render($request, $e);
}
如果我在浏览器中输入错误的URL,它会返回一个空白页面。我有:
'debug' => env('APP_DEBUG', true),
在app.php中。
有人能帮我吗,如何在路由未找到时显示404页面?谢谢。