douli1872 2016-01-16 08:39
浏览 214
已采纳

Laravel自定义控制器出现404错误

i have simple custom controller in route as :

Route::controller(
    'validationMobiles', 'ValidationMobilesController',
    [
        'getIndex' => 'validationMobiles.index',
    ]
);

unfortunately i get 404 error after run this url :

http://localhost/laravel/public/validationMobiles.index

My Controller:

namespace App\Http\Controllers;
class ValidationMobilesController extends Controller
{
    public function getIndex()
    {
        dd('ss');
    }
}

UPDATED:

full controll, this method work fine in laravel 4, in laravel 5 i added namespace:

Route::controller(
    'validationMobiles', 'ValidationMobilesController',
    [
        'getIndex' => 'validationMobiles.index',
        'postUpdate' => 'validationMobiles.update',
        'postEdit' => 'validationMobiles.edit',
        'getDelete' => 'validationMobiles.delete',
        'getAccept' => 'validationMobiles.accept',
        'getResend' => 'validationMobiles.resend',
    ]
);
  • 写回答

1条回答 默认 最新

  • dtv11049 2016-01-16 09:38
    关注

    validationMobiles.index is the name of the route you've given, not the url. If your controller method is getIndex, that method will handle a GET request to the validationMobiles/index url (http://localhost/laravel/public/validationMobiles/index).

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥100 微信小程序跑脚本授权的问题
  • ¥100 房产抖音小程序苹果搜不到安卓可以付费悬赏
  • ¥15 STM32串口接收问题
  • ¥15 腾讯IOA系统怎么在文件夹里修改办公网络的连接
  • ¥15 filenotfounderror:文件是存在的,权限也给了,但还一直报错
  • ¥15 MATLAB和mosek的求解问题
  • ¥20 修改中兴光猫sn的时候提示失败
  • ¥15 java大作业爬取网页
  • ¥15 怎么获取欧易的btc永续合约和交割合约的5m级的历史数据用来回测套利策略?
  • ¥15 有没有办法利用libusb读取usb设备数据