Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/252.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 此路由不支持GET方法。支持的方法:POST_Php_Laravel - Fatal编程技术网

Php 此路由不支持GET方法。支持的方法:POST

Php 此路由不支持GET方法。支持的方法:POST,php,laravel,Php,Laravel,我正在学习Laravel的教程,但我有一个错误: 此路由不支持GET方法。支持的方法:POST web.php的代码如下: Route::get('/', function () { return view('welcome'); }); Auth::routes(); Route::get('/p/create', 'PostsController@create'); Route::post('/p', 'PostsController@store'); Route::get('

我正在学习Laravel的教程,但我有一个错误:

此路由不支持GET方法。支持的方法:POST

web.php的代码如下:

Route::get('/', function () {
    return view('welcome');
});

Auth::routes();

Route::get('/p/create', 'PostsController@create');
Route::post('/p', 'PostsController@store');

Route::get('/profile/{user}', 'ProfilesController@index')->name('profile.show');
<form action="/p" enctype="multipart/form-data" method="POST">
        @csrf
...
create.blade.php的代码如下:

Route::get('/', function () {
    return view('welcome');
});

Auth::routes();

Route::get('/p/create', 'PostsController@create');
Route::post('/p', 'PostsController@store');

Route::get('/profile/{user}', 'ProfilesController@index')->name('profile.show');
<form action="/p" enctype="multipart/form-data" method="POST">
        @csrf
...

你有什么想法吗?

你有没有尝试过
action=“

你有没有尝试过
action=“

你能包括错误行吗

我们假设你在你的帖子中得到了错误,所以你可以在下面试试这个

你可以这样命名你的路线

Route::post('/p', 'PostsController@store')->name('post.post');
并在路线生成器中使用它,如下所示

<form action="{{ route('post.post') }}" enctype="multipart/form-data" method="POST">

您能包括错误行吗

我们假设你在你的帖子中得到了错误,所以你可以在下面试试这个

你可以这样命名你的路线

Route::post('/p', 'PostsController@store')->name('post.post');
并在路线生成器中使用它,如下所示

<form action="{{ route('post.post') }}" enctype="multipart/form-data" method="POST">

对不起,错误很小。。。 我把地址弄错了。。。我写的是“localhost:8000/p”,而不是正确的地址“localhost:8000/p/create”。
谢谢您的回答。

对不起,错误很小。。。 我把地址弄错了。。。我写的是“localhost:8000/p”,而不是正确的地址“localhost:8000/p/create”。
谢谢您的回答。

错误发生在哪一行?显然,您正试图从不支持它的页面获取
。找出它是什么,从您的代码判断,它可能是
/p/create
。我希望您没有在表单发布后在代码中执行任何重定向。很可能您正在尝试从
PostController
中的
存储
方法返回视图。但是您不能从
post
路由返回视图。而是在处理表单后重定向到
get
路由,然后从该路由返回视图。我用PostsController.php的代码更新了帖子@马丁我不知道错误发生在哪一行,我只有那个错误,没有更多的解释。错误发生在哪一行?显然,您正试图从不支持它的页面获取
。找出它是什么,从您的代码判断,它可能是
/p/create
。我希望您没有在表单发布后在代码中执行任何重定向。很可能您正在尝试从
PostController
中的
存储
方法返回视图。但是您不能从
post
路由返回视图。而是在处理表单后重定向到
get
路由,然后从该路由返回视图。我用PostsController.php的代码更新了帖子@马丁:我不知道错误发生在哪一行,我只有那个错误,没有更多的解释。请把这个标记为你的答案,然后请把这个标记为你的答案