Annotation Interface RequestParam


@Target(PARAMETER) @Retention(RUNTIME) @Documented public @interface RequestParam
Annotation that binds a method variable to a query parameter.

Example

 
  @Controller("/api")
  public class MyController {

      // Incoming request looks like "/api/user?user=123"
      @GetMapping("/user")
      public UserData getUserData(@RequestParam("user") String userId) {
          return UserDao.getUserData(userId);
      }
  }
 
 
As you can see, the @RequestParam's parameter name does not need to match the actual method parameter's name.
Since:
1.0
Version:
2022-08-31
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    Default value if the parameter is not available.
    boolean
    Indicates if the parameter is required or not.
    The name of the query parameter to map to.
  • Element Details

    • value

      String value
      The name of the query parameter to map to.
      Default:
      ""
    • required

      boolean required
      Indicates if the parameter is required or not.
      Default:
      false
    • defaultValue

      String defaultValue
      Default value if the parameter is not available.
      Default:
      "-=|NONE|=-"