[英]laravel “get” parameter not working
I am having a bit of difficulty with something simple. 我对简单的事情有点困难。
If I visit test.dev/test/1, I get the following error 如果我访问test.dev/test/1,我会收到以下错误
Symfony \ Component \ HttpKernel \ Exception \ NotFoundHttpException
Controller method not found. 未找到控制器方法。
my controller 我的控制器
<?php
class TestController extends BaseController {
public function getIndex($id)
{
return View::make('test.index');
}
}
If I remove The $id from the controller and take the 1 out of the url it works. 如果我从控制器中删除$ id并从网址中取出1,它就能正常工作。
Any ideas? 有任何想法吗?
I think you've missed the parameter in your route declaration. 我想你错过了路线申报中的参数。 Check the docs for Route Parameters .
检查路由参数的文档。
Check if your route is declared properly. 检查您的路线是否正确申报。 It should look something like this
看起来应该是这样的
Route::get(test/{id}, TestController@getIndex)
Notice the {id}
- that's the parameter you are passing to the getIndex()
method. 注意
{id}
- 这是您传递给getIndex()
方法的参数。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.