Laravel商店方法错误

时间:2017-09-24 16:27:26

标签: laravel controller

嘿伙计们我正在使用资源路线发帖我在我创建的PostsCOntroller控制器中有商店方法。

我的表格是

<div class='container-fluid'>
<form method='POST' action='PostsController@store'>
    <div class="form-group">
        <label for="exampleFormControlInput1">Text Area</label>
        <input type="text" class="form-control" 
        id="exampleFormControlInput1" placeholder="Enter Title">
    </div>

    <div class="form-group">
        <label for="exampleFormControlTextarea1">Body</label>
        <textarea class="form-control" id="exampleFormControlTextarea1" rows="5" placeholder="Enter Body"></textarea>
    </div>
    <button type="submit" class="btn btn-primary">Submit</button>

</form>

每当我clikc提交我得到这个错误

Symfony \ Component \ HttpKernel \ Exception \ MethodNotAllowedHttpException抛出消息

  

堆栈跟踪:

     

#26 Symfony \ Component \ HttpKernel \ Exception \ MethodNotAllowedHttpException   在   E:\ XAMPP \ htdocs中\ lsapp \厂商\ laravel \框架\ SRC \照亮\路由\ RouteCollection.php:255

     

#25 Illuminate \ Routing \ RouteCollection:methodNotAllowed in E:\ XAMPP \ htdocs \ lsapp \ vendor \ laravel \ framework \ src \ Illuminate \ Routing \ RouteCollection.php:242

     

#24 Illuminate \ Routing \ RouteCollection:E:\ XAMPP \ htdocs \ lsapp \ vendor \ laravel \ framework \ src \ Illuminate \ Routing \ RouteCollection.php中的getRouteForMethods:176

     

#23 Illuminate \ Routing \ RouteCollection:匹配E:\ XAMPP \ htdocs \ lsapp \ vendor \ laravel \ framework \ src \ Illuminate \ Routing \ Router.php:599

     

#22 Illuminate \ Routing \ Router:在E:\ XAMPP \ htdocs \ lsapp \ vendor \ laravel \ framework \ src \ Illuminate \ Routing \ Router.php:578

中的findRoute      

#21 Illuminate \ Routing \ Router:dispatchToRoute在E:\ XAMPP \ htdocs \ lsapp \ vendor \ laravel \ framework \ src \ Illuminate \ Routing \ Router.php:564

     

#20 Illuminate \ Routing \ Router:在E:\ XAMPP \ htdocs \ lsapp \ vendor \ laravel \ framework \ src \ Illuminate \ Foundation \ Http \ Kernel.php:176

中调度      

#19 Illuminate \ Foundation \ Http \ Kernel:Illuminate \ Foundation \ Http {closure}   在   E:\ XAMPP \ htdocs中\ lsapp \厂商\ laravel \框架\ SRC \照亮\路由\ Pipeline.php:30

     

#18 Illuminate \ Routing \ Pipeline:Illuminate \ Routing {closure}在E:\ XAMPP \ htdocs \ lsapp \ vendor \ fideloper \ proxy \ src \ TrustProxies.php:56

     

#17 Fideloper \ Proxy \ TrustProxies:处理E:\ XAMPP \ htdocs \ lsapp \ vendor \ laravel \ framework \ src \ Illuminate \ Pipeline \ Pipeline.php:149

     

#16 Illuminate \ Pipeline \ Pipeline:Illuminate \ Pipeline {closure}在E:\ XAMPP \ htdocs \ lsapp \ vendor \ laravel \ framework \ src \ Illuminate \ Routing \ Pipeline.php:53

     

#15 Illuminate \ Routing \ Pipeline:Illuminate \ Routing {closure}在E:\ XAMPP \ htdocs \ lsapp \ vendor \ laravel \ framework \ src \ Illuminate \ Foundation \ Http \ Middleware \ TransformsRequest.php:30

     

#14 Illuminate \ Foundation \ Http \ Middleware \ TransformsRequest:处理E:\ XAMPP \ htdocs \ lsapp \ vendor \ laravel \ framework \ src \ Illuminate \ Pipeline \ Pipeline.php:149

     

#13 Illuminate \ Pipeline \ Pipeline:Illuminate \ Pipeline {closure}在E:\ XAMPP \ htdocs \ lsapp \ vendor \ laravel \ framework \ src \ Illuminate \ Routing \ Pipeline.php:53

     

#12 Illuminate \ Routing \ Pipeline:Illuminate \ Routing {closure}在E:\ XAMPP \ htdocs \ lsapp \ vendor \ laravel \ framework \ src \ Illuminate \ Foundation \ Http \ Middleware \ TransformsRequest.php:30

     

#11 Illuminate \ Foundation \ Http \ Middleware \ TransformsRequest:处理E:\ XAMPP \ htdocs \ lsapp \ vendor \ laravel \ framework \ src \ Illuminate \ Pipeline \ Pipeline.php:149

     

#10 Illuminate \ Pipeline \ Pipeline:Illuminate \ Pipeline {closure}在E:\ XAMPP \ htdocs \ lsapp \ vendor \ laravel \ framework \ src \ Illuminate \ Routing \ Pipeline.php:53

     

#9 Illuminate \ Routing \ Pipeline:Illuminate \ Routing {closure}在E:\ XAMPP \ htdocs \ lsapp \ vendor \ laravel \ framework \ src \ Illuminate \ Foundation \ Http \ Middleware \ ValidatePostSize.php:27

     

#8 Illuminate \ Foundation \ Http \ Middleware \ ValidatePostSize:处理E:\ XAMPP \ htdocs \ lsapp \ vendor \ laravel \ framework \ src \ Illuminate \ Pipeline \ Pipeline.php:149

     

#7 Illuminate \ Pipeline \ Pipeline:Illuminate \ Pipeline {closure}在E:\ XAMPP \ htdocs \ lsapp \ vendor \ laravel \ framework \ src \ Illuminate \ Routing \ Pipeline.php:53

     

#6 Illuminate \ Routing \ Pipeline:Illuminate \ Routing {closure}在E:\ XAMPP \ htdocs \ lsapp \ vendor \ laravel \ framework \ src \ Illuminate \ Foundation \ Http \ Middleware \ CheckForMaintenanceMode.php:46

     

#5 Illuminate \ Foundation \ Http \ Middleware \ CheckForMaintenanceMode:handle   在   E:\ XAMPP \ htdocs中\ lsapp \厂商\ laravel \框架\ SRC \照亮\管道\ Pipeline.php:149

     

#4 Illuminate \ Pipeline \ Pipeline:Illuminate \ Pipeline {closure}在E:\ XAMPP \ htdocs \ lsapp \ vendor \ laravel \ framework \ src \ Illuminate \ Routing \ Pipeline.php:53

     

#3 Illuminate \ Routing \ Pipeline:Illuminate \ Routing {closure}在E:\ XAMPP \ htdocs \ lsapp \ vendor \ laravel \ framework \ src \ Illuminate \ Pipeline \ Pipeline.php:102

     

#2 Illuminate \ Pipeline \ Pipeline:然后在E:\ XAMPP \ htdocs \ lsapp \ vendor \ laravel \ framework \ src \ Illuminate \ Foundation \ Http \ Kernel.php:151

     

#1 Illuminate \ Foundation \ Http \ Kernel:E:\ XAMPP \ htdocs \ lsapp \ vendor \ laravel \ framework \ src \ Illuminate \ Foundation \ Http \ Kernel.php:116

中的sendRequestThroughRouter      

#0 Illuminate \ Foundation \ Http \ Kernel:处理E:\ XAMPP \ htdocs \ lsapp \ public \ index.php:55

2 个答案:

答案 0 :(得分:1)

你的行为是对的。您应该使用url not action或controller name。试试这个:

route

http://yourdomain/posts helper按路由名称生成url。在您的情况下,它将返回 if(!etPW.getText().toString().equals(etCPW.getText().toString())){ Toast.makeText(MainActivity.this,"Password Does NOT\n"+"Match Confirm Password",Toast.LENGTH_LONG).show(); etPW.setText(""); etCPW.setText(""); etPW.requestFocus(); return; }

答案 1 :(得分:0)

  1. 在文件web.php中定义您的路线

    路线::帖子(&#39;帖子&#39;,&#39; PostsController @ store&#39;) - &gt;名称(&#39; posts.store&#39;);

    < / LI>
  2. 将您的视图模板更新为