Servlets 圆形视图路径
我正在使用SpringMVC3,我所要做的就是提交一个带有post请求的表单,并将控制器上的post请求处理程序重定向到某个页面。但是当我尝试这样做时,我得到了以下错误:Servlets 圆形视图路径,servlets,spring-mvc,http-post,Servlets,Spring Mvc,Http Post,我正在使用SpringMVC3,我所要做的就是提交一个带有post请求的表单,并将控制器上的post请求处理程序重定向到某个页面。但是当我尝试这样做时,我得到了以下错误: javax.servlet.ServletException: Circular view path [thanks.htm]: would dispatch back to the current handler URL [/wickedlysmart/thanks.htm] again. Check your ViewRe
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>
我不太明白这里发生了什么事。我看到“重定向…”被记录,然后我得到这个错误。有人能帮我解决这个问题吗
谢谢。以下内容解决了问题:
@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";
}
正如您所看到的,我刚刚将重定向从“感谢”更改为“捕获”,并将重定向请求处理程序的“值”从“感谢”修改为“捕获”,并且成功了。谢谢。我将重定向从“谢谢”改为“捕获”,并将重定向请求处理程序的“值”也从“谢谢”改为“捕获”,效果良好。谢谢。@dragon66:正如你所建议的,我只是添加了一个答案,并且也接受了。谢谢