I have a route of /path/{id}, and I want my controller to detect when the id is invalid and product a 404 error page. I tried using App::abort(404);
, but this doesn't produce a 404 error - just a generic exception. How do I make it generate a 404 page?
Laravel app:abort(404)没有显示404页面
- 写回答
- 好问题 0 提建议
- 追加酬金
- 关注问题
- 邀请回答
-
1条回答 默认 最新
- douchen4547 2014-02-25 10:22关注
You have to use the Response::make or Response::view functions to generate a specific page. You can pass the error code as an argument to that. Like this:
Response::make("Page not found", 404);
Or to use a specific view, use:
return Response::view('404', array(), 404);
To display the view app/views/404.php with the http response code 404. Remember to replace the slashes with dots for the view name, so if your file is at app/views/errors/404.php, you will need to use the view name 'errors.404' for laravel to find it.
More information here: http://laravel.com/api/class-Illuminate.Support.Facades.Response.html
解决 无用评论 打赏 举报
悬赏问题
- ¥15 一直显示正在等待HID—ISP
- ¥15 Python turtle 画图
- ¥15 关于大棚监测的pcb板设计
- ¥15 stm32开发clion时遇到的编译问题
- ¥15 lna设计 源简并电感型共源放大器
- ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
- ¥15 Vue3地图和异步函数使用
- ¥15 C++ yoloV5改写遇到的问题
- ¥20 win11修改中文用户名路径
- ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入