如何更改错误页面" 哎呀,看起来出了问题。"?我想在 errors 文件夹中显示我的页面404 我的处理程序很简单:
<form action=<?php echo $filename; ?> method="post">
<br/>
<input type="submit" name="select" value="A" onclick="selecta()" />
<br/>
<input type="submit" name="select" value="B" onclick="selectb()" />
<br/>
<input type="submit" name="select" value="C" onclick="selectc()" />
</form>
<?php
function selecta(){
$filename = "a.php";
}
function selectb(){
$filename = "b.php";
}
function selectc(){
$filename = "c.php";
}
?>
答案 0 :(得分:8)
我假设您已经在 app / Exceptions / Handler.php
内counter
答案 1 :(得分:2)
将其更改为
public function handle($request)
{
try
{
return parent::handle($request);
}
catch(\Symfony\Component\HttpKernel\Exception\NotFoundHttpException $e)
{
return response()->view('Viewname', [], 404);
}
catch (Exception $e)
{
$this->reportException($e);
return $this->renderException($request, $e);
}
}
答案 2 :(得分:0)
访问handler.php
文件夹中的App\Exception
,并将默认代码更改为以下代码。
public function render($request, Exception $exception)
{
if ($this->isHttpException($exception)) {
if ($exception->getStatusCode() == 404) {
return response()->view('404', [], 404);
}
if ($exception->getStatusCode() == 403) {
return response()->view('403', [], 403);
}
}
return parent::render($request, $exception);
}