// route.php
// 直接定位到控制器是可以的额!为什么呢???
// 方法一:
Route::post('/','UserController@add');
结果:输出POST内容!!!!!
// 方法二:
Route::post('/',function (){
redirect()->action('UserController@add');
});
// 结果:
InvalidArgumentException in UrlGenerator.php line 601:
Action App\Http\Controllers\UserController@add not defined.
// UserController .php
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Http\Response
use App\Http\Controllers\Controller;
class UserController extends Controller
{
/**
* 存储新用户
*
* @param Request $request
* @return Response
*/
public function add(Request $request)
{
return new Response($request->getContent()) ;
}
}
1 个回复
宇仔
赞同来自: