-
Notifications
You must be signed in to change notification settings - Fork 38.8k
Closed as not planned
Closed as not planned
Copy link
Labels
in: webIssues in web modules (web, webmvc, webflux, websocket)Issues in web modules (web, webmvc, webflux, websocket)status: declinedA suggestion or change that we don't feel we should currently applyA suggestion or change that we don't feel we should currently applytype: enhancementA general enhancementA general enhancement
Description
It is common to use abbreviated names for query parameters in GET requests.
For example:
GET /search?q=java&y=2019&l=eng
Where q means query, y means year, and l means language.
This can then be handled using a controller method:
public SomeResponse search(SearchRequest request) {
...
}where:
public class SearchRequest {
private String q;
private String y;
private String l;
}However if we could apply @RequestParam on fields, then we could make SearchRequest more readable:
public class SearchRequest {
@RequestParam("q")
private String query;
@RequestParam("y")
private String year;
@RequestParam("l")
private String language;
}As shown in the linked SO post, it is possible to customize Spring to do this using a custom annotation (e.g. @ParamName), but I think it would be cleaner and more elegant to allow @RequestParam (and @PathVariable, etc.) on POJO fields.
References
panchenko, yauhenl, alex-pozdnyakov, Reversor, fernandezseb and 12 more
Metadata
Metadata
Assignees
Labels
in: webIssues in web modules (web, webmvc, webflux, websocket)Issues in web modules (web, webmvc, webflux, websocket)status: declinedA suggestion or change that we don't feel we should currently applyA suggestion or change that we don't feel we should currently applytype: enhancementA general enhancementA general enhancement