Laravel NotFoundHttpException
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/42166020/
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
Laravel NotFoundHttpException
提问by Michael
I have a problem with this one route.
我对这条路线有问题。
Route::get('va/{$uniqueid}','AdminController@VaShow')->name('va');
and in controller:
并在控制器中:
public function VaShow($uniqueid = '123'){
dd($uniqueid);
}
but i still get NotFoundHttpException when trying to visit route. (it have admin prefix but anyway i'm trying to access it directly with url and in view but still same) in view:
但是在尝试访问路由时我仍然收到 NotFoundHttpException。(它有 admin 前缀,但无论如何我试图直接使用 url 访问它,并且在视图中但仍然相同)在视图中:
{{route('va',['uniqueid'=>$v->uniqueid])}}
and I checked in route:list, its there:
我检查了路线:列表,它在那里:
| | GET|HEAD | admin/va/{$uniqueid} | va | App\Http\Controllers\AdminControl
ler@VaShow | web,admin |
No idea what I did wrong
不知道我做错了什么
回答by aynber
The dollar sign in your route is throwing it off. The variables in the route do not need a dollar sign:
您路线上的美元符号将其抛之脑后。路由中的变量不需要美元符号:
Route::get('va/{uniqueid}','AdminController@VaShow')->name('va');
回答by ThaTal
Try to Remove $ symbol.
尝试删除 $ 符号。
Route::get('va/{uniqueid}','AdminController@VaShow')->name('va');
回答by Juan Giraldo Soto
You don′t need the dollar sign. You could add ? at the end of the parameter in case the parameter is optional to send.
你不需要美元符号。你可以添加?在参数的末尾,以防参数可选发送。
Route::get('va/{uniqueid?}','AdminController@VaShow')->name('va');