Open
Description
When I reverse a method by specifying a get parameter with an URL, the URL is not escaped correctly.
For example, if I do:
resource.add(linkTo(methodOn(controllerClass).getCommentOfArticle(resource.getBaseUrl()+"&toto=2")).withRel("commentsOnSameNews"));
Where getCommentOfArticle is the following method inside a @RestController:
@RequestMapping(method = RequestMethod.GET)
public List<CommentResource> getCommentOfArticle(
@RequestParam("baseUrl") String baseUrl) {
return commentResourceAssembler.toResources(commentService
.getComments(baseUrl, pageUrl));
}
It will generate the following link:
http://localhost:8080/myproject/resources/comment?baseUrl=http://localhost:8080/cmstoolsWeb&toto=2
Instead of
http://localhost:8080/myproject/resources/comment?baseUrl=http%3A%2F%2Flocalhost%3A8080%2Ftest.jsp%26toto%3D2
This is verry anoying because if I escape it before, then Spring hateaos reescape my %.
So I have to this and it's really horrible :
String linkWithPageHolder = linkTo(
methodOn(controllerClass).getCommentOfArticle(
"baseUrlPlaceHolder",)).withRel(
"useless").getHref();
linkWithPageHolder = linkWithPageHolder.replaceFirst(
"baseUrlPlaceHolder",
EncodingUtil.encodeURIComponent(resource.getBaseUrl()));
String linkWithPageHolder = linkTo(
methodOn(controllerClass).getCommentOfArticle(
"baseUrlPlaceHolder", "pageUrlPlaceHolder")).withRel(
"useless").getHref();
linkWithPageHolder = linkWithPageHolder.replaceFirst(
"baseUrlPlaceHolder",
EncodingUtil.encodeURIComponent(resource.getBaseUrl()));
Metadata
Metadata
Assignees
Labels
No labels