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']);
  • 相关阅读:
    Executors源码之线程池
    Java序列化对字段名的影响
    Spring Cloud Alibaba(二)
    Security版本冲突,老版本共用服务接入新版本服务
    记一次虚拟机崩溃事件和解决方法(CentOS7)
    vue-cli 项目构建学习笔记(Vue3)
    IDEA插件-IDE Eval Reset
    Docker的学习
    Spring Security的学习
    Spring MVC框架的设计理念
  • 原文地址:https://www.cnblogs.com/yxhblogs/p/5977936.html
Copyright © 2011-2022 走看看