zoukankan      html  css  js  c++  java
  • thinkphp5.0 空模块、空控制器、空方法

    空模块

    'exception_handle'       => function(Exception $e){
            // 参数验证错误
            if ($e instanceof 	hinkexceptionValidateException) {
                return json($e->getError(), 422);
            }
    
            // 请求异常
            if ($e instanceof 	hinkexceptionHttpException && request()->isAjax()) {
                return response($e->getMessage(), $e->getStatusCode());
            }
            return redirect(url('home/index/index'));//重定向至自定义错误提示页面
        },

    或者

    'exception_handle'       => '\app\common\exception\Http',
    <?php
    namespace appcommonexception;
    use Exception;
    use thinkexceptionHandle;
    use thinkexceptionHttpException;
    class Http extends Handle
    {
    
        public function render(Exception $e)
        {
            // 参数验证错误
            if ($e instanceof ValidateException) {
                return json($e->getError(), 422);
            }
    
            // 请求异常
            if ($e instanceof HttpException && request()->isAjax()) {
                return response($e->getMessage(), $e->getStatusCode());
            }
            
            //TODO::开发者对异常的操作
            //可以在此交由系统处理
            return redirect(url('home/index/index'));//重定向至自定义错误提示页面
            //return parent::render($e);
        }
    
    }
    
    ?>

    空控制器

    // 默认的空控制器名
        'empty_controller'       => 'Error',
    <?php
    namespace apphomecontroller;
    use thinkController;
    use thinkRequest;
    
    class Error extends Controller
    {
        public function index(Request $request)
        {
            $this->redirect(url('home/index/index'));//空控制器处理        
        }
    }

    空方法

    public function _empty(){
            $this->redirect(url('home/index/index'));//空方法处理
        }
  • 相关阅读:
    CSS选择器之伪类选择器(元素)
    CSS选择器之基本选择器+属性选择器
    bugku 点击1000000次
    bugku web 5
    bugku 矛盾 30
    bugku 域名解析题 50
    bugku 好多压缩包
    六子冲 模拟棋盘
    poj3126 Prime Path(c语言)
    poj1426 Find The Multiple(c语言巧解)
  • 原文地址:https://www.cnblogs.com/xwlong/p/7844995.html
Copyright © 2011-2022 走看看