spring-projects / spring-projects/spring-hateoas
linkTo_methodOn not working on GET requested object parameter
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 1.1k
- Forks
- 476
- PR merge metrics
- No merged PRs in 30d
Description
Suppose we have this method
@RequestMapping(value= "list")
public HttpEntity<ListResource> getList(
@RequestParam(value = "text1", required = false) String text1,
@RequestParam(value = "text2", required = false) String text2,
@RequestParam(value = "text3", required = false) String text3,
...
@RequestParam(value = "page", defaultValue = "1") Integer page,
@RequestParam(value = "limit", defaultValue = "10") Integer limit) {
// ...
}
Because we have a lot of parameters, we rewrote
@RequestMapping(value= "list")
public HttpEntity<ListResource> getList(RequestObject requestObject) {
// ...
}
public class RequestObject {
private String text1;
private String text2;
private String text3;
...
private Integer page;
private Integer limit;
}
Spring MVC maps automatically the RequestObject with given parameters
But when generating the Link
final RequestObject requestObject = new RequestObject();
requestObject.setPage(1);
requestObject.setLimit(10);
requestObject.setText1("test");
return ControllerLinkBuilder.linkTo(ControllerLinkBuilder.methodOn(ABCController.class)
.getList(requestObject));
That doesn't return
http://localhost:8080/list?page=1&limit=10&text1=test
but only
http://localhost:8080/list
do you have any idea?
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.
Research direction
Start by reproducing the example with ControllerLinkBuilder.methodOn(ABCController.class).getList(requestObject), then inspect the methodOn and getList entry points for how a RequestObject argument is handled. Done means the generated link includes the populated page, limit, and text1 query parameters instead of only the path.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100