Laravel 4 中未找到控制器方法
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22559676/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Controller Method not found in Laravel 4
提问by Daniel Barde
Hi am having some sort of an issue, I created a controller and have registered it in my routes but the I keep getting an error when I try browsing to its page. The default show, create, destroy and update methods still work but the ones I create don't work I wish I knew what I am doing wrong.
您好,我遇到了一些问题,我创建了一个控制器并在我的路由中注册了它,但是当我尝试浏览到它的页面时,我不断收到错误消息。默认的 show、create、destroy 和 update 方法仍然有效,但我创建的方法不起作用我希望我知道我做错了什么。
The Error:
错误:
`Symfony \ Component \ HttpKernel \ Exception \ NotFoundHttpException
Controller method not found.`
My Route:
我的路线:
Route::Resource("impactnetwork","impactController");
Route::Resource("impactnetwork","impactController");
Route::get("impactnetwork/itinerary","impactController@itinerary");
Route::get("impactnetwork/gallery","impactController@gallery");
Route::get("impactnetwork/lead","impactController@lead");
My Controller:
我的控制器:
`public function itinerary()
{
return View::make("pages/impactitinerary");
}
public function gallery()
{
return View::make("pages/impactgallery");
}
public function lead()
{
return View::make("pages/impactlead");
}
`
I try to brwose:
我尝试 brwose:
www.mysite.dev/impactnetwork/itinerary
www.mysite.dev/impactnetwork/gallery
www.mysite.dev/impactnetwork/lead
But it keeps saying "Controller method not found"
但它一直说“找不到控制器方法”
回答by phoops
Route::resource("impactnetwork","impactController");
This defines your controller as a Resourceful controller, which have limited amount of actions.
这将您的控制器定义为 Resourceful 控制器,其动作数量有限。