Hey guys!
I am facing a problem with a multiple calls to controller (within one request) when wanting to change to a different view than default. Specifically, in class:
where when the condition is false, the default displayRecording.jsp view is used. However, when the view is changed to "displayPresentation" (the displayPresentation.jsp), the controller (the displayRecording() method) is called twice for some to me unknown reasons. When uncommenting the ModelAndView("displayRecording") line in the if-block, the controller's method again is called only once.Code:@Controller public class DisplayRecording { //.... private static int callNumber = 1; @RequestMapping("/displayRecording.do") public ModelAndView displayRecording(@RequestParam(value = "recordingId", required = false) Long recordingId, ModelMap modelMap) { System.out.println("callNumber:"+callNumber++); //.... some omitted code if (....some condition....) { // display presentation ModelAndView mav = new ModelAndView("displayPresentation"); //results in calling this controller twice // ModelAndView mav = new ModelAndView("displayRecording"); // using this does not result in two calls mav.addAllObjects(modelMap); return mav; } // display recording in the normal way: return new ModelAndView().addAllObjects(modelMap); } }
Is there any explanation for such a behaviour?
My viewResolver configuration in springmvc-servlet.xml is
and normally works just fine. And the method is not called from anywhere within my code.Code:<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="prefix" value="/jsp/" /> <property name="suffix" value=".jsp" /> </bean>
Many thanks for any ideas in advance!
Ibisek


Reply With Quote
