控制器动作被调用两次 [英] Controller action called twice

查看:84
本文介绍了控制器动作被调用两次的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Laravel开发Web应用程序,但遇到了这种奇怪"的行为.一些控制器动作被调用两次.我知道这是因为,在我的日志中,我看到(刷新一页)两组完整的条目.我的控制器动作如下所示:

I am developing an web app with Laravel and I encountered this "strange" behavior. Some controller actions are called twice. I know so because on my logs I see (for one page refresh) two full sets of entries. My controller action starts like this:

public function action_edit($rid=-1) {
    // Calc Input
    $id  = Input::get('id', $rid);
    Log::TWICE("?? {$id} - {$rid}");

其中$ rid是根据URL要求进行编辑的对象ID,但是,如果我在Input中得到一个ID,则将使用该ID.因此,当我通过以下网址调用控制器时:

where $rid is the object id to edit as requested by the url, however if I get an id in my Input, then I use this id instead. So when I call my controller via a url like:

.../mycontroller/edit/1

.../mycontroller/edit/1

我在日志文件中得到两个条目:

I get TWO entries in my log file:

2013-02-07 00:49:15 TWICE - ?? 1 - 1
2013-02-07 00:49:16 TWICE - ?? img - img

第一个是我应该看到的法线,但是第二个我不知道它是从哪里来的.我使用Chrome的开发者工具(网络"标签和控制台"标签)进行了检查,但是没有第二个请求的迹象!!我最初以为我可能会尝试使用相对资源为img或../img的某些资源,但是我没有发现任何线索.当然img是模板上我的images文件夹的名称,但是在我的代码中没有单独的相对URL img ...

The first one is the normal that I should see, however the second one I don't understand where it is coming from. I checked using the Chrome's developer tools (both network tab and console tab) but there is no sign of the second request!! I initially thought that I might try to use some resource with a relative url of img or ../img but I found no clue. Of course img is the name of my images folder on my template but there is nowhere in my code a relative url img by itself...

您对此问题有何建议?我应该在代码的其他地方进行检查/检查?还有什么可能触发第二个呼叫?

Do you have any suggestions regarding this issue? Where else in my code should I examine/check? What else could trigger the second call?

注意:我在代码的某个位置使用了以下调用,但是引用的操作是显示"而不是编辑"!

NOTE: I am using the following call at some point on my code but the referenced action is 'show' not 'edit'!!

Laravel \ Routing \ Controller :: call($ controller.'@ show',...

Laravel\Routing\Controller::call($controller.'@show', ...

提前谢谢!

Pan

推荐答案

这可能是浏览器试图请求 Favicon .

This is probably the browser trying to request a Favicon.

尝试使用curl,您很可能看不到请求.

Try with curl and you most likely won't see the request.

这篇关于控制器动作被调用两次的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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