Hi all,
I guess it is by design, but I noticed a change in RedirectView between 2.5.x and 3.0.0.RELEASE which seems a bit unusual.
In 2.5.x RedirectView only exposed primitives/wrappers in the url of the redirected view ala
In 3.0.0.RELEASE, this has changed toCode:protected boolean isEligibleProperty(String key, Object value) { return .... ClassUtils.isPrimitiveOrWrapper(value.getClass()); }
... which includes things like enums, dates, uris, urls, locales, classes etc.Code:protected boolean isEligibleProperty(String key, Object value) { return .... BeanUtils.isSimpleValueType(value.getClass()); }
I was wondering why this is now so? Under what circumstances would the default behaviour make sense?
I ask because, typically we expose reference data like enums for a form via @ModelAttribute. eg
When a form submission succeeds, we redirect to the success view. egCode:@ModelAttribute public Gender[] getGenders() { return Gender.values(); // Gender is an enum }
The RedirectView now generates urls like so:Code:@RequestMapping(...) public String saveCustomer(...) { ... return "redirect:/customers"; }
/customers?genders=MALE&genders=FEMALE
Also, I'm using the RedirectView as part of the InternalResourceViewResolver, whose behaviour is from UrlBasedViewResolver#createView(...) and that doesn't expose any configurable attribute to:
(a) create a subclass of RedirectView instead or
(b) call RedirectView#setExposeModelAttributes(false)
Can someone more familiar with the design of Spring MVC suggest why this new default behaviour makes sense? And how I can achieve what I want easily without sub-classing InternalResourceViewResolver and/or RedirectView or returning a View from my controller instead of a String.
thanks,
dave


Reply With Quote
