Symfony:奇怪的路由问题
我在 symfony 中有以下 URL(具体细节并不重要):
/frontend_dev.php/something/25/apple
...以及路由规则:
/something/:id/:word
在网站上单击时该 URL 工作正常,但在我输入 URL 时则不然。相反,symfony 说:
Unable to find a matching route to generate url for params "NULL".
奇怪的是,我可以导航到这个页面并且它可以工作,但是当在浏览器地址栏中按 Enter 时,它不再找到它。
您对造成此类事件的一般原因有什么想法吗?
我还应该补充一点,之前在地址栏中输入时 URL 工作正常,但现在就不行了,而且我不确定有什么可能会干扰它。
提前致谢。
更新:
确切的路由规则:
profile:
url: /profile/:id/:un
param: {module: profile, action: profile}
更新:
调试工具栏日志(突出显示的部分):
Unable to find a matching route to generate url for params "NULL". Toggle debug stack
#4 » in sfException::outputStackTrace() from SF_ROOT_DIR\lib\vendor\symfony\lib\exception\sfException.class.php line 110
#3 » in sfException->printStackTrace() from SF_ROOT_DIR\lib\vendor\symfony\lib\controller\sfFrontWebController.class.php line 52
#2 » in sfFrontWebController->dispatch() from SF_ROOT_DIR\lib\vendor\symfony\lib\util\sfContext.class.php line 170
#1 » in sfContext->dispatch() from SF_ROOT_DIR\web\frontend_dev.php line 13
已解决:
找到它....
我有这个在我的失败页面上的代码中:
<?php echo link_to(__('Back to previous page').' ›', $sf_request->getReferer()) ?>
在栏中输入地址时,引荐来源网址失败。
I've got following URL in symfony (specifics not important):
/frontend_dev.php/something/25/apple
... and a routing rule:
/something/:id/:word
The URL works fine when clicked through to on the site, but not when I type in the URL. Instead, symfony says:
Unable to find a matching route to generate url for params "NULL".
The weird thing is that I can navigate to this page and it works, but when hitting Enter in the browser address bar, it no longer finds it.
Any thoughts on what might be the cause of something like this generally?
I should also add that the URL was working fine when typed in the address bar earlier, but doesn't anymore, and I'm not sure what's there that might be interfering with it.
Thanks in advance.
UPDATE:
The exact routing rule:
profile:
url: /profile/:id/:un
param: {module: profile, action: profile}
UPDATE:
Debug toolbar log (the higlighted part):
Unable to find a matching route to generate url for params "NULL". Toggle debug stack
#4 » in sfException::outputStackTrace() from SF_ROOT_DIR\lib\vendor\symfony\lib\exception\sfException.class.php line 110
#3 » in sfException->printStackTrace() from SF_ROOT_DIR\lib\vendor\symfony\lib\controller\sfFrontWebController.class.php line 52
#2 » in sfFrontWebController->dispatch() from SF_ROOT_DIR\lib\vendor\symfony\lib\util\sfContext.class.php line 170
#1 » in sfContext->dispatch() from SF_ROOT_DIR\web\frontend_dev.php line 13
RESOLVED:
Found it....
I had this in my code on the failing page:
<?php echo link_to(__('Back to previous page').' ›', $sf_request->getReferer()) ?>
The referer fails when typing address into bar.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
除非您忘记提及您通常从表单导航到此页面,并且缺少 POST 数据会扰乱路由;我认为这不是——这肯定是你的浏览器的问题。
您是否在系统上的不同浏览器中尝试过此操作?
如果您仍然遇到问题,可以复制
routing.yml
的相关部分吗?Unless you're neglecting to mention that you navigate to this page usually from forms and it's the lack of POST data that is upsetting the routing; which I'm thinking this is not- this surely must be an issue with your browser.
Have you tried this in a different browser on your system?
If you're still having issues can you copy in the relevant section of your
routing.yml
?我在实时站点上收到此错误消息,发现问题是由数据库中的字段动态填充的 link_to 命令。
然而该字段为空,因此 link_to 没有收到链接信息。
I was getting this error message on a live site and found the issue to be a link_to command which was being dynamically populated by a field from the database.
However the field was null, so the link_to received no link info.