zoukankan      html  css  js  c++  java
  • Laravel中的路由管理

    //路由中输出视图
    Route::get('/', function () {
    return view('welcome');
    });

    //get路由请求
    Route::get('get',function(){
    return 'get路由请求';
    });

    //post路由请求
    Route::post('post',function(){
    return 'post请求';
    });

    //多路由请求
    Route::match(['get','post'],'match',function(){
    return '多路由请求';
    });

    //任意路由请求
    Route::any('any',function(){
    return '任意路由请求';
    });

    //路由参数
    Route::get('user/{id}',function($id){
    return 'user-id-'.$id;
    });

    //路由参数默认值
    Route::get('user/{name?}',function($name = 'yxh'){
    return 'user-name-'.$name;
    });

    //路由参数的正则验证
    Route::get('user/{id}/{name?}',function($id,$name = 'yxh'){
    return 'user-id-'.$id.'-name-'.$name;
    })->where(['id'=>'[0-9]+','name'=>'[A-Za-z]+']);

    //路由别名
    Route::get('user/member-center',['as'=>'center',function(){
    return route('center');
    }]);

    //路由群组
    Route::group(['prefix'=>'member'],function(){
    //路由别名
    Route::get('user/member-center',['as'=>'center',function(){
    return route('center');
    }]);

    //任意路由请求
    Route::any('any',function(){
    return '任意路由请求';
    });
    });

    //路由中输出视图
    Route::get('view',function(){
    return view('welcome');
    });

    //关联控制器
    Route::get('member/info','MemberController@info');

    Route::get('test','UserController@test');

    Route::get('query','UserController@query');

    Route::get('orm','UserController@orm');

    Route::get('section1',['uses'=>'UserController@section1']);

    Route::get('url',['as'=>'url','uses'=>'UserController@urlTest']);
  • 相关阅读:
    PowerDesigner_15连接Oracle11g,反向工程导出模型图
    angular学习
    GoEasy消息推送
    Spring 工作原理
    JAVA解析HTML,获取待定元素属性
    设计模式之工厂方法模式
    设计模式之单例模式
    通过Java代码获取系统信息
    centos7下NAT模式下设置静态ip
    关于在Spring项目中使用thymeleaf报Exception parsing document错误
  • 原文地址:https://www.cnblogs.com/yxhblogs/p/5977936.html
Copyright © 2011-2022 走看看