我正在尝试使用Routes呼叫控制器。使用GET方法时一切正常。当我在Post工作时,我无法呼叫控制器。请检查以下内容。
错误代码:路由无效
Route::post('/accountSignUp', [
'as' => 'accountSignUp',
'uses' => 'UsersController@accountSignUp'
]);
任何人都可以建议如何做。
我签入了日志..获取以下错误消息..
[2014-11-07 13:30:46] dev.ERROR: exception 'Symfony\Component\HttpKernel\Exception\NotFoundHttpException' in /var/www/project_name/vendor/laravel/framework/src/Illuminate/Routing/RouteCollection.php:148
Stack trace:
#0 /var/www/project_name/vendor/laravel/framework/src/Illuminate/Routing/Router.php(1049): Illuminate\Routing\RouteCollection->match(Object(Illuminate\Http\Request))
#1 /var/www/project_name/vendor/laravel/framework/src/Illuminate/Routing/Router.php(1017): Illuminate\Routing\Router->findRoute(Object(Illuminate\Http\Request))
#2 /var/www/project_name/vendor/laravel/framework/src/Illuminate/Routing/Router.php(996): Illuminate\Routing\Router->dispatchToRoute(Object(Illuminate\Http\Request))
#3 /var/www/project_name/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(775): Illuminate\Routing\Router->dispatch(Object(Illuminate\Http\Request))
#4 /var/www/project_name/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(745): Illuminate\Foundation\Application->dispatch(Object(Illuminate\Http\Request))
#5 /var/www/project_name/vendor/barryvdh/laravel-debugbar/src/Middleware/Stack.php(34): Illuminate\Foundation\Application->handle(Object(Illuminate\Http\Request), 1, true)
#6 /var/www/project_name/vendor/laravel/framework/src/Illuminate/Session/Middleware.php(72): Barryvdh\Debugbar\Middleware\Stack->handle(Object(Illuminate\Http\Request), 1, true)
#7 /var/www/project_name/vendor/laravel/framework/src/Illuminate/Cookie/Queue.php(47): Illuminate\Session\Middleware->handle(Object(Illuminate\Http\Request), 1, true)
#8 /var/www/project_name/vendor/laravel/framework/src/Illuminate/Cookie/Guard.php(51): Illuminate\Cookie\Queue->handle(Object(Illuminate\Http\Request), 1, true)
#9 /var/www/project_name/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Illuminate\Cookie\Guard->handle(Object(Illuminate\Http\Request), 1, true)
#10 /var/www/project_name/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(641): Stack\StackedHttpKernel->handle(Object(Illuminate\Http\Request))
#11 /var/www/project_name/public/index.php(49): Illuminate\Foundation\Application->run()
#12 {main} [] []
答案 0 :(得分:0)
首先,您应该以这种方式定义路线:
Route::method(['POST', 'GET'], '/accountSignUp', [
'as' => 'accountSignUp',
'uses' => 'UsersController@accountSignUp'
]);
现在在您的控制器中获取任何值,您只需使用echo Input::get('username')
- 您对POST和GET数据都使用get
方法。