404 未找到,但 Laravel 5.4 中存在路由 [英] 404 Not Found, but route exist in Laravel 5.4

查看:34
本文介绍了404 未找到,但 Laravel 5.4 中存在路由的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 PhpStorm.我可以运行并打开index.php,但是当我想按提交按钮(登录后)时,找不到它的显示 404.

I'm using PhpStorm. I can run and open the index.php, but when I want to press submit button (post sign in), its display 404 not found.

在 Windows 10 上运行的 Web 服务器 Apache 2.4.

Web server Apache 2.4 running on Windows 10.

这是我的家

这是我的路线

推荐答案

我不完全确定为什么所有的反对票,特别是因为这是一个常见的问题,并且对于 Laravel 环境的新手来说原因可能被隐藏.我知道这是一篇旧帖子,但我将其添加在这里以供将来的新手使用.

I'm not entirely sure why all the down-votes, especially since this is a common issue and the cause can be hidden for someone new to the Laravel environment. I know this is an old post, but I add it here for future newbies.

我建议尝试的第一件事是从命令行(从您的项目根目录)运行 php artisan route:list.这将列出 Laravel 可以注册的所有路由,如果有任何错误,通常它们会显示在这里.

The first thing I suggest trying is running php artisan route:list from the command line (from your project root directory). This will list all the routes that Laravel can register and if there are any errors, usually they will show up here.

我建议的第二件事是确保 URL 与路由匹配.我无法告诉你有多少次我试图弄清楚为什么我的路由返回 404 只是因为我的表单在我的路由被定义为 时发布到类似 /insertStudent 的东西/admin/insertStudent

The second thing I suggest is to ensure that the URL matches route. I can't tell you how many times I've tried to figure out why my route was returning a 404 simply because my form was posting to something like /insertStudent when my route was defined as /admin/insertStudent

我建议的第三件事是确保您正在调用的方法存在.你的方法真的被称为 postSignInpostInsertStudent 而不是简单的 SignInInsertStudent 吗?请记住,URL 和方法名称都区分大小写,并且应该与您定义路由的位置、被调用的 URL 以及接收请求的方法相匹配.

The third thing I suggest is to ensure the method you are calling exists. Are your methods really called postSignIn and postInsertStudent and not simply SignIn and InsertStudent? Keep in mind that both the URL and method names are case sensitive and should match where you define the route, the URL that is being called, and the method that is receiving the request.

最后,如果所有这些都检查出来,我建议您尝试的最后一件事是运行 php artisan route:clear.这会重置路由缓存.

Finally if all that checks out, one last thing I might suggest you try is running php artisan route:clear. This resets the route cache.

这篇关于404 未找到,但 Laravel 5.4 中存在路由的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆