Circular viewing path

I am using Spring MVC 3, and all I am trying to do is submit a form with an email request and redirect the mail request handler to the controller on some page. But I get the following error when I try to do this:

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.) 

The following is the code I'm 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"; } 

Viewing permission in the context of a Spring application:

 <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="prefix" value="" /> <property name="suffix" value=".htm" /> </bean> 

I do not quite understand what is happening here. I see that "redirect .." is logged, and then I get this error. Can someone help me on this?

Thanks.

+4
source share
1 answer

After solving 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 can see, I just changed the redirection from “thank you” to “captured” and changed the “value” for the redirect request handler from “thanks” to “captured”, and it worked. Thanks.

+1
source

Source: https://habr.com/ru/post/1412191/


All Articles