RouteCollection.php第179行中的Laravel(1/1)NotFoundHttpException [英] Laravel (1/1) NotFoundHttpException in RouteCollection.php line 179

查看:485
本文介绍了RouteCollection.php第179行中的Laravel(1/1)NotFoundHttpException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在laravel中提交表单时遇到问题.我的表单结构看起来像这样.

I've encountered a problem submitting my form in laravel. My form structure looks this.

<form  class="form-group" action="{{ route('writepoem') }}" 
method="post" name="publish" enctype="multipart/form-data"  
onsubmit="return validateForm();">
   <input type="hidden" name="_token" value="{{ Session::token() }}">
   <input type="text" name="user">
   <textarea name="poem"></textarea>
   <input type="submit" value="save">
</form>

我的web.php文件具有此路由.

My web.php file has this route.

Route::post('/writepoem', ['uses'=>'PoemController@postCreatePoem','as'=>'writepoem']);

我的PoemController.

My PoemController.

namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Poem;

class PoemController extends Controller
{ 
    public function postCreatePoem(Request $request)
    {   
        //validation
        $poem=new Poem();
        $poem->poem=$request['poem'];
        $poem->user=$request['user'];



        //save poem
        $request->user()->poems()->save($poem);
        return redirect()->route('feed');
    }
}

提交表单时,我会收到此异常.

On submitting my form I get this Exception.

(1/1)NotFoundHttpException

(1/1) NotFoundHttpException

在RouteCollection.php第179行中.

in RouteCollection.php line 179.

路由问题可能是什么?

推荐答案

我发现我的表单是通过

`require resource_path().'/sub-folder/write.php'`

,这就是导致错误的原因.

and that was causing the error.

我将表格移到了主文档,并且问题已解决.

I moved the form to the main document and my issue was fixed.

这篇关于RouteCollection.php第179行中的Laravel(1/1)NotFoundHttpException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆