當我在我的edit
表單上單擊Submit
後,嘗試訪問http://localhost:8000/dashboard.user.update
時,此錯誤發生在我的laravel 5.1項目中。Laravel 5.1 - 路由錯誤 - RouteCollection.php中的NotFoundHttpException行143:
NotFoundHttpException in RouteCollection.php line 143:
當我在我的控制器中運行update
函數時發生此錯誤。運行index
或show
等其他功能時,我沒有錯誤。
這是我的路線:
...
// Dashboard routes...
Route::resource('dashboard/user', 'UserController');
Route::resource('dashboard', 'DashboardController');
...
我已經運行php artisan route:list
,看看我的路由工作:
+--------+----------+-----------------------+------------------------+---------------------------------------------+------------+
| Domain | Method | URI | Name | Action | Middleware |
+--------+----------+-----------------------+------------------------+---------------------------------------------+------------+
...
| | POST | dashboard/user | dashboard.user.store | App\Http\Controllers\[email protected] | auth |
| | GET|HEAD | dashboard/user | dashboard.user.index | App\Http\Controllers\[email protected] | auth |
| | GET|HEAD | dashboard/user/create | dashboard.user.create | App\Http\Controllers\[email protected] | auth |
| | DELETE | dashboard/user/{user} | dashboard.user.destroy | App\Http\Controllers\[email protected] | auth |
| | GET|HEAD | dashboard/user/{user} | dashboard.user.show | App\Http\Controllers\[email protected] | auth |
| | PUT | dashboard/user/{user} | dashboard.user.update | App\Http\Controllers\[email protected] | auth |
| | PATCH | dashboard/user/{user} | | App\Http\Controllers\[email protected] | auth |
...
現在我不知道該怎麼辦,能幫忙嗎?
你不應該訪問way..it應該是http路線://本地主機:8000 /儀表板/用戶/ ID是ID是的標識用戶 – JLPuro
@JLPuro,yes,'localhost:8000/dashboard/user/user_id'是顯示數據時的訪問方式。運行'localhost:8000/dashboard/user/user_id'到'show'或'localhost:8000/dashboard/user/user_id/edit'到'edit'我沒有錯誤。我需要的是'更新'。 – wahyueka31
@JLPuro,順便說一句,使用'http:// localhost:8000/dashboard.user.update'不是我的方式來訪問路由。拉拉維爾做到了。該URI顯示在我的瀏覽器URL中。 – wahyueka31