gpt4 book ai didi

php - Laravel 4 显示 MethodNotAllowedHttpException

转载 作者:搜寻专家 更新时间:2023-10-31 21:26:47 26 4
gpt4 key购买 nike

我在点击地址栏时遇到此错误,

我从数据库中获取数据并发送到 View ,该 View 运行良好,但是当我点击地址栏选项卡时它显示Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException任何帮助对我来说都是很好的...

在我的 Controller 中:

public function getpiece()
{
$reportno = $_POST['reportno'];
$data = DB::table('reportno')->where('reportno','=',$reportno)->get();


if(empty($data)) {
return \Redirect::to('dashboard/client/piece')
->with('status','error')
->with('message','Data Not Available');
} else {
return \View::make('dashboard.client.piecewisereport')
->with('data',$data);
}
}

最佳答案

它不起作用,因为当您在地址栏中点击 enter 时,它会尝试使用 GET 而不是 POST,但它只找到一个 POST 路由。 (路线::邮寄)。

要解决此问题,请执行以下操作:

Route::any('getpiece','Controllers\Domain\Client\ClientController@getpiece');

然后我建议使用类似

的东西
if (Request::isMethod('post'))
{
//
}

if (Request::isMethod('get'))
{
//
}

包装你的代码。有关更多信息,请参阅 Request Information docs

另一种方法是直接从路由寻址 Controller ,可以在这里找到:Laravel 4.2 Implicit Controllers

注意:这些文档链接链接到 Laravel 4.2。

关于php - Laravel 4 显示 MethodNotAllowedHttpException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34947226/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com