【问题标题】:laravel 5.7 route collection error, notfoundhttpexception how can i solve it?laravel 5.7 路由收集报错,notfoundhttpexception 怎么解决?
【发布时间】:2018-11-06 07:34:00
【问题描述】:

我从 angularjs 发送 id 以获取 id 相关的特定记录,这是我的 angularjs 代码。

$http.post("getSingleRecord",{"id": id})
.success(function(response){
 console.log(response);
});

在我的 laravel 控制器中,我收到了这样的数据。我已经在 framework/src/illuminate/routing/router.php 中定义了我的路由器。但我在第 179 行的 Routing/RouteCollection.php 中收到此错误 NotFoundHttpException。在 web.php 中,我刚刚返回 Auth::routes();我所有的路线都在工作,但只有这条不工作

$this->post("/getSingleRecord/{id}","controller@getRecord");

当然在我的控制器方法中,即; getRecord,我收到了这样的 id,但我没有得到任何 id,任何帮助将不胜感激,谢谢

$id = $request->route('id'); //laravel 5.7
print_r($id); //just want to see the id here
exit();

【问题讨论】:

    标签: angularjs kendo-grid laravel-5.7


    【解决方案1】:

    您的 Laravel 路由需要 url 中的参数,但您在 POST 数据中发送它。

    试试这个:

    $http.post(`getSingleRecord/${id}`,{})
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-05-09
      • 2017-08-10
      • 1970-01-01
      • 2014-02-10
      • 1970-01-01
      • 2016-09-25
      • 1970-01-01
      相关资源
      最近更新 更多