You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want to create a link to a controller method that does not use single @RequestParam annotations for each query parameter. Instead I pass an object containing all query parameters. This works fine despite that the self link I am constructing does not contain the query parameters that I am passing:
@GetMapping
public PagedModel<EntityModel<FooDto>> findBy(
@Valid Query query,
@PageableDefault(size = 5) Pageable pageable,
PagedResourcesAssembler<FooDto> assembler) {
final Link link =
linkTo(methodOn(Controller.class).findBy(query, pageable, assembler))
.withSelfRel()
.expand();
final Page<FooDto> fooList = fooService.findBy(query, pageable);
return assembler.toModel(fooList, link);
}
The result I get when requesting http://localhost:8080/foo?param1=bar looks like this:
I want to create a link to a controller method that does not use single @RequestParam annotations for each query parameter. Instead I pass an object containing all query parameters. This works fine despite that the self link I am constructing does not contain the query parameters that I am passing:
@GetMapping
public PagedModel<EntityModel<FooDto>> findBy(
@Valid Query query,
@PageableDefault(size = 5) Pageable pageable,
PagedResourcesAssembler<FooDto> assembler) {
final Link link =
linkTo(methodOn(Controller.class).findBy(query, pageable, assembler))
.withSelfRel()
.expand();
final Page<FooDto> fooList = fooService.findBy(query, pageable);
return assembler.toModel(fooList, link);
}
The result I get when requesting http://localhost:8080/foo?param1=bar looks like this:
I want to create a link to a controller method that does not use single
@RequestParam
annotations for each query parameter. Instead I pass an object containing all query parameters. This works fine despite that the self link I am constructing does not contain the query parameters that I am passing:The result I get when requesting
http://localhost:8080/foo?param1=bar
looks like this:It does not contain the query parameters in the self link. Any chance to make this work? I cannot find any documentation on query parameters when building links expect this one here: https://docs.spring.io/spring-hateoas/docs/current/reference/html/#server.link-builder.webmvc.methods.request-params which does not help me.
Thanks in advance :)
The text was updated successfully, but these errors were encountered: