Laravel 5.2 不正确的路由模型绑定不显示 404

Laravel 5.2 Incorrect Route Model Binding does not show 404

在Laravel 5.2关于隐式路由模型绑定的文档中,写着:

If a matching model instance is not found in the database, a 404 HTTP response will be automatically generated.

路线:

Route::get('/product/{product}',function(Product $product){ 
     dd($product); 
});

当我输入 URL 参数存在的 ID 时,一切都按预期进行。但是当我输入 URL 不存在的产品 ID 时,我得到的是 No query results for model [App\Product]. 而不是 response 404。有什么想法吗?

经过搜索我找到了解决方案。如果您在 resources/views/errors 中没有指定错误模板文件,将显示默认 Laravel 消息。只需在 resources/views/errors.

中创建 404.blade.php 文件