数据库 - Model 前置说明
官方开源项目 抓取代理IP

介绍

@RequestMapping()注解,主要用于绑定请求的路由地址。

用法

场景:声明路由地址。
支持:HTTPWebSocket
注解:@RequestMapping()

参数:

  • route=""

    • 功能:路由地址
    • 值单位:字符串
    • 默认值:无
  • method=""

    • 功能:允许的请求类型,默认为空表示不限制,多个类型允许用|号间隔,例如:method="GET|POST"
    • 值单位:字符串
    • 默认值不限制,非必填
  • method=""

    • 功能:路由描述
    • 值单位:字符串
    • 默认值,非必填

使用案例

<?php
namespace app\http;
use x\controller\Http;

class Index extends Http
{
    /**
     * @RequestMapping(route="index/test", method="GET", title="我是测试路由")
    */
    public function index() {
        return $this->fetch('只允许GET,我的路由是:index/test');
    }

    /**
     * @RequestMapping(route="index/demo", method="POST")
    */
    public function demo() {
        return $this->fetch('只允许POST,我的路由是:index/demo');
    }
}

SW-X

企业级 - 高性能 PHP 框架

最后更新:3年前 . 作者-小黄牛

本篇目录