《Springboot极简教程》问题解决:javax.servlet.ServletException: Circular view path [login]: would dispatch back to the current handler URL
2017-09-13 14:26
1326 查看
javax.servlet.ServletException: Circular view path [login]: would dispatch back to the current handler URL [/login] again. Check your ViewResolver setup! (Hint: This may be the result of an unspecified view, due to default view name generation.) .......
原因
当没有声明ViewResolver时,spring会注册一个默认的ViewResolver,就是JstlView的实例, 该对象继承自InternalResoureView。JstlView用来封装JSP或者同一Web应用中的其他资源,它将model对象作为request请求的属性值暴露出来, 并将该请求通过javax.servlet.RequestDispatcher转发到指定的URL.
Spring认为, 这个view的URL是可以用来指定同一web应用中特定资源的,是可以被RequestDispatcher转发的。
也就是说,在页面渲染(render)之前,Spring会试图使用RequestDispatcher来继续转发该请求。
代码:
if (path.startsWith("/") ? uri.equals(path) : uri.equals(StringUtils.applyRelativePath(uri, path))) { throw new ServletException("Circular view path [" + path + "]: would dispatch back " + "to the current handler URL [" + uri + "] again. Check your ViewResolver setup! " + "(Hint: This may be the result of an unspecified view, due to default view name generation.)"); }
从这段代码可以看出,如果你的view name和你的path是相同的字符串,根据Spring的转发规则,就等于让自己转发给自己,会陷入死循环。所以Spring会检查到这种情况,于是抛出Circular view path异常。
还有一种情况是,日志虽然报了这段,但是原因其实是viewResolver配置错误。
解决
通过原因分析,造成问题有两个因素:缺省转发
view和path同名
所以,解决方案如下
1.消除缺省转发
2.修改view和path,让他们不同名
相关文章推荐
- javax.servlet.ServletException: Circular view path [index]: would dispatch back to the current handl
- Circular view path [index]: would dispatch back to the current handler URL [/index] again.
- Circular view path : would dispatch back to the current handler URL again. Check your ViewResolver s
- Circular view path [home]: would dispatch back to the current handler URL [/home] again. Check your ViewResolver setup!
- Circular view path [login3]: would dispatch back to the current handler URL [/Spring_Demo/login3]
- Circular view path [faults]: would dispatch back to the current handler URL [/pulsar/faults] again
- spring cloud 报[Circular view path [refundbbb]: would dispatch back to the current handler URL [/refu
- Spring boot 报错:Circular view path [...]: would dispatch back to the current handler
- Circular view path [...]: would dispatch back to the current handler
- Circular view path [...]: would dispatch back to the current handler
- spring boot would dispatch back to the current handler URL [/hello] again. Check your ViewResolver s
- 【HTML5入门】解决The superclass javax.servlet.http.HttpServlet was not found on the Java Build Path问题
- javax.servlet.ServletException: Circular view path......Check your ViewResolver setup!
- 解决"The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path"问题
- 解决“The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path”问题
- JSP页面顶端出现错误:The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path的问题解决
- 项目忽然出现 The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path 解决方法
- 关于“Windows cannot access the specified device, path, or file. You may not have the appropriate permissions to access the item.”问题的解决
- Android Device Monitor的 “provide the path to the Android SDK”问题解决方案
- 在Eclipse中编写servlet时出现"The import javax.servlet cannot be resolved" 问题解决办法