laravel - Laravel 得到 Internal Server Error 怎么解决?
问题描述
Laravel 得到 Internal Server Error 怎么解决?
这是我的 web.php 代码
Route::get('/', function () {
return view('index');
});
Route::get('/fleet', 'FleetController@index')->name('fleet');
Route::get('/offers', 'OffersController@index')->name('Offers');
当我链接到车队页面时,我会收到内部服务器错误。
我的文件夹是
resources
|-view
|--index.blade.php
|--fleet.blade.php
|--offers.blade.php
这是 index.blade.php 代码
<li class="nav-item"><a class="nav-link" href="{{ route('fleet') }}">Fleet</a></li>
<li class="nav-item"><a class="nav-link" href="{{ route('offers') }}">Offers</a></li>
怎么解决?
我的 apache 设置是
DocumentRoot "D:\xampp\htdocs\laravel\wine\public"
我的 FleetController 代码
public function index()
{
return view('index');
}
舰队模型
class Fleet extends Model
{
//
}
仍然得到错误
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator at postmaster@localhost to inform them of the time this error occurred, and the actions you performed just before this error.
More information about this error may be available in the server error log.
Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.
Apache/2.4.43 (Win64) OpenSSL/1.1.1g PHP/7.4.6 Server at localhost Port 80
解决方案
请进一步了解laravel Route
最基本的 Laravel 路由只接受 aURI
和 aClosure
现在看看你的代码
Route::get('/fleet')->name('fleet');
Route::get('/offers')->name('offers');
你只给URI
但你不给关闭
基本路线:
Route::get('/fleet',function(){
// what do you want to do with that URI
})->name('fleet');
您还可以为控制器操作指定路由名称:
Route::get('user/profile', 'UserProfileController@show')->name('profile');
您需要UserProfileController
为上述路线创建一个文件
推荐阅读
- javascript - 连接到不同的数据库 +singleton + node.js
- android - 我正在使用 android 分页库,但不是以块的形式获取数据,而是一次性获取完整列表
- tcp - 在 JMeter 中为整个运行保持相同的 TCP 连接
- git - 什么是使用 URl 结帐
- google-analytics - 谷歌分析网络小部件
- javascript - 在 JavaScript 和 HTML 中,我怎样才能访问当前按钮所在的位置?
- database - 删除ORACLE DB中其他表中用作外键的表中的所有行
- javascript - 如何使用带有 RXJS 的对象将 Array 中的值(true 或 false 转换为 Yes 或 No)?
- sql - 如何遍历表格并获取单元格的值?(MVC)
- java - Java 练习:在网格中生成当前月份的日历输出