SpringMVC配拦截器报错[dispatcherServlet]:Servlet.service() for servlet [dispatcherServlet] threw exception
这个可以说是一个很麻烦的bug了 看日志文件也看不出代码具体哪里出现异常
2020-03-18 11:41:23.585 ERROR 3644 --- [nio-8080-exec-3] o.a.c.c.C.[.[.[.[dispatcherServlet]: Servlet.service() for servlet [dispatcherServlet] threw exceptionjava.lang.StackOverflowError: null
at javax.servlet.http.HttpServletRequestWrapper.getSession(HttpServletRequestWrapper.java:244) ~[tomcat-embed-core-9.0.31.jar:9.0.31]
at org.apache.catalina.core.ApplicationHttpRequest.getSession(ApplicationHttpRequest.java:582) ~[tomcat-embed-core-9.0.31.jar:9.0.31]
at javax.servlet.http.HttpServletRequestWrapper.getSession(HttpServletRequestWrapper.java:244) ~[tomcat-embed-core-9.0.31.jar:9.0.31]
at org.apache.catalina.core.ApplicationHttpRequest.getSession(ApplicationHttpRequest.java:582) ~[tomcat-embed-core-9.0.31.jar:9.0.31]
at javax.servlet.http.HttpServletRequestWrapper.getSession(HttpServletRequestWrapper.java:244) ~[tomcat-embed-core-9.0.31.jar:9.0.31]
at org.apache.catalina.core.ApplicationHttpRequest.getSession(ApplicationHttpRequest.java:582) ~[tomcat-embed-core-9.0.31.jar:9.0.31]
at javax.servlet.http.HttpServletRequestWrapper.getSession(HttpServletRequestWrapper.java:244) ~[tomcat-embed-core-9.0.31.jar:9.0.31]
at org.apache.catalina.core.ApplicationHttpRequest.getSession(ApplicationHttpRequest.java:582) ~[tomcat-embed-core-9.0.31.jar:9.0.31]
at javax.servlet.http.HttpServletRequestWrapper.getSession(HttpServletRequestWrapper.java:244) ~[tomcat-embed-core-9.0.31.jar:9.0.31]
at org.apache.catalina.core.ApplicationHttpRequest.getSession(ApplicationHttpRequest.java:582) ~[tomcat-embed-core-9.0.31.jar:9.0.31]
at javax.servlet.http.HttpServletRequestWrapper.getSession(HttpServletRequestWrapper.java:244) ~[tomcat-embed-core-9.0.31.jar:9.0.31]
at org.apache.catalina.core.ApplicationHttpRequest.getSession(ApplicationHttpRequest.java:582) ~[tomcat-embed-core-9.0.31.jar:9.0.31]
at javax.servlet.http.HttpServletRequestWrapper.getSession(HttpServletRequestWrapper.java:244) ~[tomcat-embed-core-9.0.31.jar:9.0.31]
at org.apache.catalina.core.ApplicationHttpRequest.getSession(ApplicationHttpRequest.java:582) ~[tomcat-embed-core-9.0.31.jar:9.0.31]
at javax.servlet.http.HttpServletRequestWrapper.getSession(HttpServletRequestWrapper.java:244) ~[tomcat-embed-core-9.0.31.jar:9.0.31]
at org.apache.catalina.core.ApplicationHttpRequest.getSession(ApplicationHttpRequest.java:582) ~[tomcat-embed-core-9.0.31.jar:9.0.31]
at javax.servlet.http.HttpServletRequestWrapper.getSession(HttpServletRequestWrapper.java:244) ~[tomcat-embed-core-9.0.31.jar:9.0.31]
at org.apache.catalina.core.ApplicationHttpRequest.getSession(ApplicationHttpRequest.java:582) ~[tomcat-embed-core-9.0.31.jar:9.0.31]
at javax.servlet.http.HttpServletRequestWrapper.getSession(HttpServletRequestWrapper.java:244) ~[tomcat-embed-core-9.0.31.jar:9.0.31]
at org.apache.catalina.core.ApplicationHttpRequest.getSession(ApplicationHttpRequest.java:582) ~[tomcat-embed-core-9.0.31.jar:9.0.31]
at javax.servlet.http.HttpServletRequestWrapper.getSession(HttpServletRequestWrapper.java:244) ~[tomcat-embed-core-9.0.31.jar:9.0.31]
at org.apache.catalina.core.ApplicationHttpRequest.getSession(ApplicationHttpRequest.java:582) ~[tomcat-embed-core-9.0.31.jar:9.0.31]
at javax.servlet.http.HttpServletRequestWrapper.getSession(HttpServletRequestWrapper.java:244) ~[tomcat-embed-core-9.0.31.jar:9.0.31]
at org.apache.catalina.core.ApplicationHttpRequest.getSession(ApplicationHttpRequest.java:582) ~[tomcat-embed-core-9.0.31.jar:9.0.31]
at javax.servlet.http.HttpServletRequestWrapper.getSession(HttpServletRequestWrapper.java:244) ~[tomcat-embed-core-9.0.31.jar:9.0.31]
at org.apache.catalina.core.ApplicationHttpRequest.getSession(ApplicationHttpRequest.java:582) ~[tomcat-embed-core-9.0.31.jar:9.0.31]
at javax.servlet.http.HttpServletRequestWrapper.getSession(HttpServletRequestWrapper.java:244) ~[tomcat-embed-core-9.0.31.jar:9.0.31]
at org.apache.catalina.core.ApplicationHttpRequest.getSession(ApplicationHttpRequest.java:582) ~[tomcat-embed-core-9.0.31.jar:9.0.31]
at javax.servlet.http.HttpServletRequestWrapper.getSession(HttpServletRequestWrapper.java:244) ~[tomcat-embed-core-9.0.31.jar:9.0.31]
at org.apache.catalina.core.ApplicationHttpRequest.getSession(ApplicationHttpRequest.java:582) ~[tomcat-embed-core-9.0.31.jar:9.0.31]
at javax.servlet.http.HttpServletRequestWrapper.getSession(HttpServletRequestWrapper.java:244) ~[tomcat-embed-core-9.0.31.jar:9.0.31]
at org.apache.catalina.core.ApplicationHttpRequest.getSession(ApplicationHttpRequest.java:582) ~[tomcat-embed-core-9.0.31.jar:9.0.31]
at javax.servlet.http.HttpServletRequestWrapper.getSession(HttpServletRequestWrapper.java:244) ~[tomcat-embed-core-9.0.31.jar:9.0.31]
at org.apache.catalina.core.ApplicationHttpRequest.getSession(ApplicationHttpRequest.java:582) ~[tomcat-embed-core-9.0.31.jar:9.0.31]
配置了登录的拦截器 然后项目就没成功跑起来过 把拦截器去掉就可以正常访问
上百度搜了半天也没查出个所以然来 很无奈
最后打了断点 发现代码一直在拦截器类的执行前方法里不停的做死循环递归
如下图:
文章图片
后来觉得可能是拦截的路径出问题了 导致请求转发的路径也被拦截了
可明明已经放行该路径了呀
仔细看了半天 发现放行路径少写了个斜杠 /
文章图片
就是在红线地方的斜杠 必须要加!!! 【SpringMVC配拦截器报错[dispatcherServlet]:Servlet.service() for servlet [dispatcherServlet] threw exception】
文章图片
文章图片
完美解决
推荐阅读
- vue-cli|vue-cli 3.x vue.config.js 配置
- 爱琐搭配(喜欢复古、冷淡,像这种双环设计的气质耳环)
- opencv|opencv C++模板匹配的简单实现
- 【亲测好用】高逼格配色网站推荐
- 从战略性的角度可以配置股票
- 世界之大,包罗万象--|世界之大,包罗万象-- 读《我不过低配的人生》
- 2019-08-29|2019-08-29 iOS13适配那点事
- Android6.0~9.0适配
- 春季试衣间|春季试衣间|UNIQLO优衣库 UR HOTWIND热风春夏新品搭配 日常搭配 可盐可甜
- 缓存有关的配置和属性