Hi everyone,
This is kind of a stupid question but i can't seem to find an answer for it. I'm also not sure if this question has been asked but i did a pretty good search and came up with nothing.
I was wondering if you can use 1 controller to view many pages?
I have a libraryController (implements Controller) that gives basically gives you a list of books
Code:public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception { if (log.isDebugEnabled()) { log.debug("entering 'handleRequest' method..."); } return new ModelAndView("admin/library", referenceData(request,null,null));
but I need this same controller for another page "admin/editLibrary", "public/publicLibrary" and a few others. Instead of copying and creating the exact same controller with different beans to declare and urlMapping in the servlet i was wondering if i can just use this same controller.
like having:
-LibraryController
-EditLibraryController
-PublicLibraryController
all being the same thing except for the last return part being different at the view.
and then in the servlet having:
Code:<bean id="libraryController" class="org.library.controller.LibraryController"> <property name="bookManager"><ref bean="bookManager" /></property> </bean> <bean id="editLibraryController" class="org.library.controller.EditLibraryController"> <property name="bookManager"><ref bean="bookManager" /></property> </bean> <bean id="publicLibraryController" class="org.library.controller.PulblicLibraryController"> <property name="bookManager"><ref bean="bookManager" /></property> </bean>
I just need to display some data for those pages. Is there a general way with all Controllers (simpleFormController).
Thanks a lot for all the help. This forum ROCKS!![/code]


Reply With Quote