1、项目在tomcat6,启动正常。登陆首页正常
2、但是在tomcat7,下启动正常,登陆首页报错
严重: Servlet.service() for servlet [cms] in context with path [/cms] threw exception [Request processing failed; nested exception is java.lang.IllegalArgumentException: Control character in cookie value or attribute.] with root cause
java.lang.IllegalArgumentException: Control character in cookie value or attribute.
at org.apache.tomcat.util.http.CookieSupport.isHttpSeparator(CookieSupport.java:192)
at org.apache.tomcat.util.http.CookieSupport.isHttpToken(CookieSupport.java:214)
at org.apache.tomcat.util.http.ServerCookie.appendCookieValue(ServerCookie.java:187)
at org.apache.catalina.connector.Response.generateCookieString(Response.java:1038)
at org.apache.catalina.connector.Response.addCookie(Response.java:981)
at org.apache.catalina.connector.ResponseFacade.addCookie(ResponseFacade.java:373)
at org.springframework.web.util.CookieGenerator.addCookie(CookieGenerator.java:165)
at org.springframework.web.servlet.i18n.CookieLocaleResolver.setLocale(CookieLocaleResolver.java:119)
at com.gcms.cms.web.AdminLocaleInterceptor.preHandle(AdminLocaleInterceptor.java:43)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:761)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:716)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:647)
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:552)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:198)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:240)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:164)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:462)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:562)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:395)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:250)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:188)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:166)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:302)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:744)
------解决方案--------------------
编码问题
------解决方案--------------------
7 的 要求严格了
------解决方案--------------------
应该是因为tomcat7中cookie对中文的支持不够好~
------解决方案--------------------
你用英文尝试个cookie 应该可以 , 。现在报错就是 Control character in cookie
------解决方案--------------------
环境不一致是容易出一些奇怪的问题~参考一下:参考
不光是页面的编码,主要是你用cookie存中文的时候再设置一次编码~
------解决方案--------------------
就是cookie 问题,你先删除,试试看
------解决方案--------------------
你在过滤器里面打印下存储的cookie。中文的话先encode存进去。
tomcat7对cookie中文支持不友好