gpt4 book ai didi

php - Laravel 5.2 在 Handler.php 第 103 行抛出 NotFoundHttpException

转载 作者:行者123 更新时间:2023-12-01 15:40:22 25 4
gpt4 key购买 nike

当我添加基本路线 (foo) 时会发生这种情况。其余路线按预期工作。这会生成 NotFoundHttpException 和 ModelNotFoundException。

app/Http/routes.php:

Route::auth();

Route::get('/home', 'HomeController@index');

Route::get('/index','WosController@index');
Route::get('/create','WosController@create');
Route::get('/{workorder}','WosController@show');
Route::post('/create','WosController@store');

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

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

app/resources/views/foo.blade.php:

<p>foo</p>

最佳答案

在声明你的路由文件时,尝试将 WosController@show 声明为最后一个路由。像这样:

Route::auth();

Route::get('/home', 'HomeController@index');

Route::get('/index','WosController@index');
Route::get('/create','WosController@create');
Route::post('/create','WosController@store');

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

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

Route::get('/{workorder}','WosController@show');

Laravel 可能在你的展示路线上犯了一个错误,因为它认为 /foo{workorder} 的一个参数,因为它无法区分它们。所以,在声明路由的时候,尽量把固定路由放在前面,带参数的路由放在最后。

关于php - Laravel 5.2 在 Handler.php 第 103 行抛出 NotFoundHttpException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38252038/

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