【问题标题】:Laravel 3 routing with URI keeps giving 404 error带有URI的Laravel 3路由不断给出404错误
【发布时间】:2014-04-23 01:36:32
【问题描述】:

需要使用 URI 在 laravel 3 中发送一个 id。我知道在 L4 中它的 {whatever} 但我被这个项目的 L3 (:any) 卡住了。我不断收到 404,因为它在一个不存在的控制器“报价”中寻找它 - 我需要它来使用 Shipquote 控制器。

我试过这个:

Route::any('quotes/ship/view/(:any)', 'Shipquote@viewQuote');

...没用。我试过这个作为测试:

Route::any('quotes/ship/view/test', 'Shipquote@viewQuoteTest');

...成功了。

我也试过了:

Route::any('quotes/ship/view/(:any)', function($id)
{
 return Controller::call('Shipquote@viewQuote', array($id));
});

...也没有用。尝试使用 Route::any、Route::get 和 Route::post 但仍然得到 404。

任何帮助表示赞赏

【问题讨论】:

    标签: laravel http-status-code-404 laravel-routing


    【解决方案1】:

    原来我只需要上床睡觉。第二天就成功了……:S

    无论如何,为了给这篇文章加分,这里有一点基础知识:

    Dynamic routing in Laravel 3
              Route::any('some/path/and/(:any)', 'someController@someFunction');
              Route::any('some/path/and/(:num)', 'someController@someFunction');
              Route::any('some/path/and/(:all)', 'someController@someFunction');
    
    Dynamic routing in Laravel 4
              Route::any('some/path/and/{$someval}', 'someController@someFunction');
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-01-15
      • 1970-01-01
      • 2020-11-15
      • 2013-12-26
      • 2014-12-21
      • 2017-10-20
      • 2018-01-18
      • 2019-07-08
      相关资源
      最近更新 更多