【发布时间】:2012-05-20 23:50:47
【问题描述】:
我正在使用 Spring MVC 3,我想做的只是提交一个带有发布请求的表单并将控制器上的发布请求处理程序重定向到某个页面。但是当我尝试这样做时出现以下错误:
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.)
以下是我正在使用的代码:
请求处理程序:
@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";
}
在 Spring 应用上下文中查看解析器:
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="" />
<property name="suffix" value=".htm" />
</bean>
我不太明白这里发生了什么。我看到“重定向..”被记录,然后我得到这个错误。有人可以帮我解决这个问题吗?
谢谢。
【问题讨论】:
-
我将重定向从“thanks”更改为“captured”,并将重定向请求处理程序的“value”也从“thanks”更改为“captured”,并且成功了。谢谢。
-
@dragon66:就像你建议的那样,我刚刚添加了一个答案并接受了它。谢谢。
标签: servlets spring-mvc http-post