Annotation Interface RsqlSpec


@Target(PARAMETER) @Retention(RUNTIME) @Documented public @interface RsqlSpec
Marks a controller method parameter to be automatically resolved as a Specification from an RSQL query string.

When applied to a method parameter, the annotated parameter will receive a Specification built from the RSQL query provided in the HTTP request. The RSQL query is parsed, validated against the configured query contract, and converted into a Spring Data JPA Specification.

Validation behavior depends on WebQuery configuration on the same method:

  • Entity-aware mode (dtoClass = void.class): selectors are validated against entity fields annotated with RsqlFilterable, with optional alias support from FieldMapping.
  • DTO-aware mode: selectors are validated against DTO fields annotated with RsqlFilterable and translated to entity paths through MapsTo.

Example usage in a controller:


 @GetMapping("/users")
 @WebQuery(entityClass = User.class)
 public List<User> search(
     @RsqlSpec(paramName = "filter") Specification<User> spec
 ) {
     return userRepository.findAll(spec);
 }
 

If the query parameter is not present in the request, the Specification will be equivalent to Specification.unrestricted(), returning all results.

See Also:
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    The name of the query parameter that contains the RSQL string.
  • Element Details

    • paramName

      String paramName
      The name of the query parameter that contains the RSQL string. Defaults to "filter".
      Returns:
      the HTTP request query parameter name
      Default:
      "filter"