-
Notifications
You must be signed in to change notification settings - Fork 38.8k
Description
Rossen Stoyanchev opened SPR-8484 and commented
As part of #12200, milestone 2 of Spring 3.1, support was added to automatically expose @PathVariable
values in the model. This is quite useful in cases where a view prepares links to related URLs (#11152). However, it can get in the way in cases where the model is used in an automated way such as when model attributes are appended to a redirect URL (#13094), or when views generate the response from the model - MarshallingView, MappingJacksonJsonView.
Rather than adding path variables to the model prior to invoking the controller method (like @ModelAttribute
), path variables can be added via AbstractView.render(..)
, which already deals with adding static attributes and a RequestContext. This has several advantages:
- The feature applies only to methods not annotated with
@ResponseBody
- View types can decide individually (e.g. turned off by default for MarshallingView and MappingJacksonJsonView)
- Applications can override the default settings via AbstractView and UrlBasedViewResolver
Affects: 3.1 M2
Issue Links:
- Automatically expose @PathVariables in the Model [SPR-7543] #12200 Automatically expose
@PathVariables
in the Model