spring-hateoas icon indicating copy to clipboard operation
spring-hateoas copied to clipboard

LinkBuilder doesn't include Matrix Variables

Open dennisstritzke opened this issue 9 years ago • 2 comments
trafficstars

If an endpoint uses Matrix Variables and you try to create a link to this method, the passed matrix variables aren't inserted into the link. The issue popped up in this Stack Overflow question.

See the following endpoint as an example:

@RequestMapping(value = "/matrix", method = RequestMethod.GET)
public HttpEntity> example(
      @MatrixVariable String first,
      @MatrixVariable(required = false) String second) {
  return new HttpEntity("first=" + first + " second=" + second);
}

Using linkTo(methodOn(MvcController.class).example("First", "Second")).withSelfRel().getHref(); produces http://localhost:8090/matrix whereas it should be http://localhost:8090/matrix;first=First;second=Second

As I outlined in the SO answer it is most likely that the UriBuilder implementation just doesn't consider matrix parameters:

  1. See this part of the UriTemplate. It uses different variable types to build the Uri. A matrix parameter isn't one of them.
  2. See the VariableType enum, which was used to do the switch on. There is also no matrix param.

There should be a possibility to create links with matrix variables.

dennisstritzke avatar Mar 01 '16 21:03 dennisstritzke

Hey Dennis, Did you find any solution for this? I am running into same issue, i was not able to generate the link as I am using matrix variables in my endpoint.

SusheelGurudu avatar Sep 29 '17 15:09 SusheelGurudu

Please fix this. I need it.

onacit avatar Apr 05 '23 11:04 onacit