I just spent some time replacing my defaultannotationhandlermapping with RequestMappingHandlerMapping in order to be able to use the Flash scope in Spring. I thought it might be a nice way to simplify my handlers and avoid ugly urls.
A typical handler scenario that I want to support with this is:
So, a model should be able to be either contain Flash attributes for redirection purposes or be a "normal" model for regular display purposes.
SomeEntity entity = mgr.get(id);
model.addFlashAttribute("status","Something went wrong: " + entity.getLabel());
So I thought I could just replace ModelMap with RedirectAttributes. Get a few extra options, cool! However, RedirectAttributes tries to format all objects I add to it through model.addAttribute to Strings, I suppose so it can put them in a URL if it has to. Of course, this makes it useless as a ModelMap for display purposes.
I just want to be able to use FlashAttributes and not have to worry about clearing models and such. The idea is to reduce complexity after all and get rid of those ugly url strings! Any suggestions on the correct way of using this?