-
Notifications
You must be signed in to change notification settings - Fork 38.8k
Closed
Closed
Copy link
Labels
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
Jochen Pier opened SPR-15267 and commented
Dear Spring-Team,
we often use @ModelAttribute to fetch Model-Attributes from the model in controller actions.
Example:
@RequestMapping("/testAtrribute")
public @ResponseBody String action(@ModelAttribute(name = "attr", binding=false) String attr) {
return "Received from Model:" + attr;
}The problem: If we forget the "binding=false" attribute, we get a really heavy security risk. Additionally, I think that getting something from the existing Model (which was constructed from former processing) or binding data to request are very different things, that should get different names.
So I suggest to introduce a new name and deprecate the "binding=false" attribute.
Name-suggestion: @FromModel(name="xyz")
Example:
@RequestMapping("/testAtrribute")
public @ResponseBody String action(@FromModel(name = "attr") String attr) {
return "Received from Model:" + attr;
}And maybe another suggestion:
Rename the parameter-binding annotation too.
So
@RequestMapping("/testAtrribute")
public @ResponseBody String action(@FromRequest("Book") Book book) {
return "Received from Request:" + book.getTitle();
}Thank you for spring!
Issue Links:
- Prevent binding for @ModelAttribute [SPR-13402] #17982 Prevent binding for
@ModelAttribute
Metadata
Metadata
Assignees
Labels
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