spring-projects / spring-projects/spring-hateoas
Request param value with curly braces throws IllegalArgumentException
Open
@odrotbohm is already working on this.
Since May 21, 2015.
in: core
process: waiting for feedback
stack: webmvc
unlikely
- Dominant language
- Java
- Stars
- 1.1k
- Forks
- 476
- PR merge metrics
- No merged PRs in 30d
Description
Example:
@ResponseBody
@RequestMapping(value = "", method = RequestMethod.GET)
public Resources<FileResource> listFilesHal(
@RequestParam(value = "q") String query) {
Link self = linkTo(methodOn(FileRestController.class).listFilesHal(query)).withSelfRel();
return new Resources<>(listFilesImpl(query), self);
}
If q contains curly braces (and it does because it's JSON) then linkTo throws
GET http://localhost:8080/files?q={"foo": "bar"}
java.lang.IllegalArgumentException: Map has no value for '"foo"'
at org.springframework.web.util.UriComponents$MapTemplateVariables.getValue(UriComponents.java:276)
at org.springframework.web.util.UriComponents.expandUriComponent(UriComponents.java:221)
at org.springframework.web.util.HierarchicalUriComponents.expandInternal(HierarchicalUriComponents.java:326)
at org.springframework.web.util.HierarchicalUriComponents.expandInternal(HierarchicalUriComponents.java:46)
at org.springframework.web.util.UriComponents.expand(UriComponents.java:152)
at org.springframework.web.util.UriComponentsBuilder.buildAndExpand(UriComponentsBuilder.java:302)
at org.springframework.hateoas.mvc.ControllerLinkBuilderFactory.linkTo(ControllerLinkBuilderFactory.java:145)
at org.springframework.hateoas.mvc.ControllerLinkBuilder.linkTo(ControllerLinkBuilder.java:135)
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.