注释类型 DataVariable


已过时。
变量定义注解 不再建议使用此注解,变量定义请使用 com.dtflys.forest.annotation.Var

该注解只能修饰方法参数,被修饰的参数表示为一个可被模板字符串引用的变量,不会直接通过请求传输到服务端。

通过该注解定义变量的方式如下:

         @Get(url = "http://localhost:8080/user/${userId}")
         UserInfo getUser(@DataVariable("userId") String id);
     

如上所示,id参数会先被定义成一个名为"userId"的变量,然后通过@Get注解的url属性中的 "...${userId}" 部分所引用, 如果此方法被这样调用 getUser("U001") , 那么最终产生的url为 http://localhost:8080/user/U001
因为此时传入参数id为字符串"U001",即给变量"userId"同样赋值为"U001",最后url中的"${userId}"部分引用了该变量

从以下版本开始:
2016-05-24
作者:
gongjun
  • 可选元素概要

    可选元素
    修饰符和类型
    可选元素
    说明
    已过时。
    The filters will do some processing for the variable value before sending request.
    已过时。
    The name of the variable.
  • 元素详细资料

    • value

      String value
      已过时。
      The name of the variable. The variable name can be referenced in some places (ex. request URL, Body, Headers)
      返回:
      variable name
      默认值:
      ""
    • filter

      String filter
      已过时。
      The filters will do some processing for the variable value before sending request.
      返回:
      filter name
      默认值:
      ""