I am using Spring MVC 3 and all I am trying to do is submitting a form with post request and redirecting the post request handler on the controller to some page. But I am getting the following error when I try to do that:
javax.servlet.ServletException: Circular view path [thanks.htm]: would dispatch back to the current handler URL [/wickedlysmart/thanks.htm] again. Check your ViewResolver setup! (Hint: This may be the result of an unspecified view, due to default view name generation.)
Following is the code I am using:
Request handler:
@RequestMapping(method=RequestMethod.GET, value="thanks")
public ModelAndView thanks() {
logger.debug("redirecting..");
return new ModelAndView("thanks");
}
@RequestMapping(method = RequestMethod.POST, value="talk")
public String processContactForm(HttpServletRequest req) {
//...
return "redirect:thanks";
}
View resolver in spring application context:
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="" />
<property name="suffix" value=".htm" />
</bean>
I am not quite able to understand what is going on here. I see "redirecting.." being logged and then I get this error. Could someone help me with this issue?
Thanks.
Following solved the problem:
@RequestMapping(method=RequestMethod.GET, value="captured")
public ModelAndView thanks() {
logger.debug("redirecting..");
return new ModelAndView("thanks");
}
@RequestMapping(method = RequestMethod.POST, value="talk")
public String processContactForm(HttpServletRequest req) {
//...
return "redirect:captured";
}
As you could see, I just changed the redirect from "thanks" to "captured" and modified the "value" for the redirect request handler from "thanks" to "captured" as well and it worked. Thanks.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With