I'm new to Spring MVC Restful. Suppose I have index.jsp which forwards user to a form page where user could submit a term to search. I catch the term with a POST handler method, and then do some calculation and hope to redirect the result to be used at another page (/WEB-INF/jsp), for example, we say build a graph based on the result. The problem is how to gather the results and redirect the URL at the same time. The Controllers like below:
By searching, I found that Spring View Resolver only could process the redirected jsp under root directory (as same with index.jsp). In this case, the "result" seems not accepted by "graphPage". I also included UrlBasedViewResolver in XXX-servlet.xml as following:Code:@RequestMapping(value="/termForm", method = RequestMethod.GET) public ModelAndView setupForm() { Term termClass = new Term(); return new ModelAndView("term", "command", termClass); } @RequestMapping(value="/getTerm", method=RequestMethod.POST) public String getTerms(@ModelAttribute("term") Term term, BindingResult result) { String label = term.getTerm(); //doing some calculation to term here result = .... return "redirect:"+ "graphPage.jsp"; }
Sorry for the long question, please give any hint to do this. Thanks a lot.Code:<bean id="viewResolver" class="org.springframework.web.servlet.view.UrlBasedViewResolver"> <property name="viewClass" value="org.springframework.web.servlet.view.JstlView" /> <property name="prefix" value="/WEB-INF/jsp/" /> <property name="suffix" value=".jsp" /> </bean>


Reply With Quote
