报错很长,报错信息如下
2020-03-17 19:57:36.708 ERROR 1207 --- [nio-8080-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] threw exception java.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]
还有很长的循环代码报错
经过调试发现代码总是在这两句之间循环,这里产生了死循环,为啥会在这里产生死循环呢?
我们判断出user == null 于是就重定向到/index.html,而/index.html也是被拦截的,所以又回到了if里边,就开始了死循环
别问我怎么知道的,因为:
这里不拦截的index.html我忘了前边的斜杠了,正确写法应该是/index.html
这样就可以正常跳转了