Spring MVC报错500: Circular view path [xxx]: would dispatch back to the current handler URL

描述 & 错误

Spring MVC报错500: Circular view path [xxx]: would dispatch back to the current handler URL_第1张图片
响应码500

Type: Exception Report

Message: Circular view path [updateUserinfo]: would dispatch back to the current handler URL [/shop/updateUserinfo] again. Check your ViewResolver setup! (Hint: This may be the result of an unspecified view, due to default view name generation.)

Description: The server encountered an unexpected condition that prevented it from fulfilling the request.

原因 & 解决

一般是映射处理这个url请求的控制器 方法返回值问题

  1. 比如没有跳转页面,没有返回对象(即void)则报错
  2. 控制器处理方法跳转到映射的请求反复也会如此
@RequestMapping(value = "/updateUserinfo", method = RequestMethod.POST)
public void updateUserinfo(Userinfo userinfo) throws IOException {
	....
    return;
}

这个返回值类型为void, 方法体也没有跳转页面的话,则会包这个错误。
如果把返回值类型改为String(并不配置视图解析器映射), 对应的是返回404而已

解决方法比较简单,就是规避原因即可。比如修改返回类型,也可以返回JSON,页面跳转等等

你可能感兴趣的:(SSM,框架开发,Spring,MVC)