|
From: Timo V. <sic...@gm...> - 2004-06-28 21:07:57
|
Alef, > <servlet> > <servlet-name>blah</servlet-name> > > <servlet-class>org.spfr.web.servlet.DispatcherServlet</servlet-class> > <init-param> > <param-name>detectAllViewResolvers</param-name> > <param-name>false</param-name> > </init-param> > </servlet> Thanks, I'll try that. My email should've gone to the user's list, sorry! > Just curious, why do you need to do this? You've extended a > controller and implemented a the viewresolvers interface? I've written two ViewResolvers: a RedirectViewResolver and a DelegatingViewResolver. On resolveViewName() the RedirectViewResolver takes any view-name, creates a new RedirectView and returns that. The DelegatingViewResolver dispatches view names to registered ViewResolvers based on a prefix in the viewName; it has a default ViewResolver if no prefix matches. In my setup, for instance, "redirect:http://www.springframework.org" would be delegated to my RedirectViewResolver (without the "redirect:" prefix). I wrote about this a while ago. Juergen said, it was not in the spirit of spring to have the controller know anything about the view; i.e. prefixing the viewName to influence the rendering. Basically, I agree, but I needed to do it anyway, since it solved a problem: I have controllers in my web-app, which need to setup a fairly complex model for e.g. a "viewCustomer" view. When I need to view a customer from a different controller, e.g. after a completed "updateCustomer" form-view, I had the choice to copy-paste the complex model-creation code, or to redirect to the original "viewCustomer" view. Well, instead of copy-paste I could've abstracted things away, but I preferred the second solution anyway, since it allowed users to set bookmarks correctly. Since I want to stay in spring spirit, i.e. I do not want to hardcode the RedirectView creation and the redirection address in my update controllers, I store "redirect:viewCustomer" in the successView property via XML (and pass the customerId in the model). Regards, Timo |