Annotation 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 withRsqlFilterable, with optional alias support fromFieldMapping. - DTO-aware mode: selectors are validated against DTO fields annotated with
RsqlFilterableand translated to entity paths throughMapsTo.
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
-
Element Details
-
paramName
String paramNameThe name of the query parameter that contains the RSQL string. Defaults to "filter".- Returns:
- the HTTP request query parameter name
- Default:
"filter"
-