• springboot 1.5.x 使用tomcat8设置cookie的domain以dot开头报错


    "C:Program FilesJavajdk1.7.0_75injava" -XX:TieredStopAtLevel=1 -noverify -Dspring.output.ansi.enabled=always "-javaagent:C:Program FilesJetBrainsIntelliJ IDEA 2017.1.4libidea_rt.jar=61656:C:Program FilesJetBrainsIntelliJ IDEA 2017.1.4in" -Dfile.encoding=UTF-8 -classpath "C:Program FilesJavajdk1.7.0_75jrelibcharsets.jar;C:Program FilesJavajdk1.7.0_75jrelibdeploy.jar;C:Program FilesJavajdk1.7.0_75jrelibextaccess-bridge-64.jar;C:Program FilesJavajdk1.7.0_75jrelibextdnsns.jar;C:Program FilesJavajdk1.7.0_75jrelibextjaccess.jar;C:Program FilesJavajdk1.7.0_75jrelibextlocaledata.jar;C:Program FilesJavajdk1.7.0_75jrelibextsunec.jar;C:Program FilesJavajdk1.7.0_75jrelibextsunjce_provider.jar;C:Program FilesJavajdk1.7.0_75jrelibextsunmscapi.jar;C:Program FilesJavajdk1.7.0_75jrelibextzipfs.jar;C:Program FilesJavajdk1.7.0_75jrelibjavaws.jar;C:Program FilesJavajdk1.7.0_75jrelibjce.jar;C:Program FilesJavajdk1.7.0_75jrelibjfr.jar;C:Program FilesJavajdk1.7.0_75jrelibjfxrt.jar;C:Program FilesJavajdk1.7.0_75jrelibjsse.jar;C:Program FilesJavajdk1.7.0_75jrelibmanagement-agent.jar;C:Program FilesJavajdk1.7.0_75jrelibplugin.jar;C:Program FilesJavajdk1.7.0_75jrelib
    esources.jar;C:Program FilesJavajdk1.7.0_75jrelib
    t.jar;D:workspacesworkspace_learningSpringBoot-LearningChapter4-2-6	argetclasses;D:maven_repo
    epositoryorgspringframeworkootspring-boot-starter-actuator1.5.2.RELEASEspring-boot-starter-actuator-1.5.2.RELEASE.jar;D:maven_repo
    epositoryorgspringframeworkootspring-boot-starter1.5.2.RELEASEspring-boot-starter-1.5.2.RELEASE.jar;D:maven_repo
    epositoryorgspringframeworkootspring-boot1.5.2.RELEASEspring-boot-1.5.2.RELEASE.jar;D:maven_repo
    epositoryorgspringframeworkootspring-boot-autoconfigure1.5.2.RELEASEspring-boot-autoconfigure-1.5.2.RELEASE.jar;D:maven_repo
    epositoryorgspringframeworkootspring-boot-starter-logging1.5.2.RELEASEspring-boot-starter-logging-1.5.2.RELEASE.jar;D:maven_repo
    epositorychqoslogbacklogback-classic1.1.11logback-classic-1.1.11.jar;D:maven_repo
    epositorychqoslogbacklogback-core1.1.11logback-core-1.1.11.jar;D:maven_repo
    epositoryorgslf4jjcl-over-slf4j1.7.24jcl-over-slf4j-1.7.24.jar;D:maven_repo
    epositoryorgslf4jjul-to-slf4j1.7.24jul-to-slf4j-1.7.24.jar;D:maven_repo
    epositoryorgslf4jlog4j-over-slf4j1.7.24log4j-over-slf4j-1.7.24.jar;D:maven_repo
    epositoryorgyamlsnakeyaml1.17snakeyaml-1.17.jar;D:maven_repo
    epositoryorgspringframeworkootspring-boot-actuator1.5.2.RELEASEspring-boot-actuator-1.5.2.RELEASE.jar;D:maven_repo
    epositoryorgspringframeworkspring-context4.3.7.RELEASEspring-context-4.3.7.RELEASE.jar;D:maven_repo
    epositoryorgspringframeworkootspring-boot-starter-web1.5.2.RELEASEspring-boot-starter-web-1.5.2.RELEASE.jar;D:maven_repo
    epositoryorgspringframeworkootspring-boot-starter-tomcat1.5.2.RELEASEspring-boot-starter-tomcat-1.5.2.RELEASE.jar;D:maven_repo
    epositoryorgapache	omcatembed	omcat-embed-core8.5.11	omcat-embed-core-8.5.11.jar;D:maven_repo
    epositoryorgapache	omcatembed	omcat-embed-el8.5.11	omcat-embed-el-8.5.11.jar;D:maven_repo
    epositoryorgapache	omcatembed	omcat-embed-websocket8.5.11	omcat-embed-websocket-8.5.11.jar;D:maven_repo
    epositoryorghibernatehibernate-validator5.3.4.Finalhibernate-validator-5.3.4.Final.jar;D:maven_repo
    epositoryjavaxvalidationvalidation-api1.1.0.Finalvalidation-api-1.1.0.Final.jar;D:maven_repo
    epositoryorgjbossloggingjboss-logging3.3.0.Finaljboss-logging-3.3.0.Final.jar;D:maven_repo
    epositorycomfasterxmlclassmate1.3.3classmate-1.3.3.jar;D:maven_repo
    epositorycomfasterxmljacksoncorejackson-databind2.8.7jackson-databind-2.8.7.jar;D:maven_repo
    epositorycomfasterxmljacksoncorejackson-annotations2.8.0jackson-annotations-2.8.0.jar;D:maven_repo
    epositorycomfasterxmljacksoncorejackson-core2.8.7jackson-core-2.8.7.jar;D:maven_repo
    epositoryorgspringframeworkspring-web4.3.7.RELEASEspring-web-4.3.7.RELEASE.jar;D:maven_repo
    epositoryorgspringframeworkspring-aop4.3.7.RELEASEspring-aop-4.3.7.RELEASE.jar;D:maven_repo
    epositoryorgspringframeworkspring-beans4.3.7.RELEASEspring-beans-4.3.7.RELEASE.jar;D:maven_repo
    epositoryorgspringframeworkspring-webmvc4.3.7.RELEASEspring-webmvc-4.3.7.RELEASE.jar;D:maven_repo
    epositoryorgspringframeworkspring-expression4.3.7.RELEASEspring-expression-4.3.7.RELEASE.jar;D:maven_repo
    epositoryorgslf4jslf4j-api1.7.24slf4j-api-1.7.24.jar;D:maven_repo
    epositoryorgspringframeworkspring-core4.3.7.RELEASEspring-core-4.3.7.RELEASE.jar" com.didispace.DemoApplication
    
      .   ____          _            __ _ _
     /\ / ___'_ __ _ _(_)_ __  __ _    
    ( ( )\___ | '_ | '_| | '_ / _` |    
     \/  ___)| |_)| | | | | || (_| |  ) ) ) )
      '  |____| .__|_| |_|_| |_\__, | / / / /
     =========|_|==============|___/=/_/_/_/
     :: Spring Boot ::        (v1.5.2.RELEASE)
    
    2017-09-13 10:07:06.855  INFO 8184 --- [           main] com.didispace.DemoApplication            : Starting DemoApplication on MS-20160524XDZU with PID 8184 (D:workspacesworkspace_learningSpringBoot-LearningChapter4-2-6	argetclasses started by Administrator in D:workspacesworkspace_learningSpringBoot-LearningChapter4-2-6)
    2017-09-13 10:07:06.858  INFO 8184 --- [           main] com.didispace.DemoApplication            : No active profile set, falling back to default profiles: default
    2017-09-13 10:07:06.944  INFO 8184 --- [           main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@32a7c990: startup date [Wed Sep 13 10:07:06 GMT+08:00 2017]; root of context hierarchy
    2017-09-13 10:07:09.295  INFO 8184 --- [           main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8080 (http)
    2017-09-13 10:07:09.308  INFO 8184 --- [           main] o.apache.catalina.core.StandardService   : Starting service Tomcat
    2017-09-13 10:07:09.310  INFO 8184 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet Engine: Apache Tomcat/8.5.11
    2017-09-13 10:07:09.403  INFO 8184 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
    2017-09-13 10:07:09.403  INFO 8184 --- [ost-startStop-1] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 2462 ms
    2017-09-13 10:07:09.759  INFO 8184 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean  : Mapping servlet: 'dispatcherServlet' to [/]
    2017-09-13 10:07:09.768  INFO 8184 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'metricsFilter' to: [/*]
    2017-09-13 10:07:09.769  INFO 8184 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'characterEncodingFilter' to: [/*]
    2017-09-13 10:07:09.770  INFO 8184 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
    2017-09-13 10:07:09.770  INFO 8184 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'httpPutFormContentFilter' to: [/*]
    2017-09-13 10:07:09.770  INFO 8184 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'requestContextFilter' to: [/*]
    2017-09-13 10:07:09.770  INFO 8184 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'webRequestLoggingFilter' to: [/*]
    2017-09-13 10:07:09.771  INFO 8184 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'applicationContextIdFilter' to: [/*]
    2017-09-13 10:07:10.617  INFO 8184 --- [           main] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for @ControllerAdvice: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@32a7c990: startup date [Wed Sep 13 10:07:06 GMT+08:00 2017]; root of context hierarchy
    2017-09-13 10:07:10.707  INFO 8184 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/test],methods=[GET]}" onto public java.lang.String com.didispace.DemoApplication.testLogLevel(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
    2017-09-13 10:07:10.713  INFO 8184 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
    2017-09-13 10:07:10.714  INFO 8184 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],produces=[text/html]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
    2017-09-13 10:07:10.798  INFO 8184 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
    2017-09-13 10:07:10.798  INFO 8184 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
    2017-09-13 10:07:10.896  INFO 8184 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
    2017-09-13 10:07:11.430  INFO 8184 --- [           main] o.s.b.a.e.mvc.EndpointHandlerMapping     : Mapped "{[/info || /info.json],methods=[GET],produces=[application/vnd.spring-boot.actuator.v1+json || application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
    2017-09-13 10:07:11.433  INFO 8184 --- [           main] o.s.b.a.e.mvc.EndpointHandlerMapping     : Mapped "{[/loggers/{name:.*}],methods=[GET],produces=[application/vnd.spring-boot.actuator.v1+json || application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.LoggersMvcEndpoint.get(java.lang.String)
    2017-09-13 10:07:11.434  INFO 8184 --- [           main] o.s.b.a.e.mvc.EndpointHandlerMapping     : Mapped "{[/loggers/{name:.*}],methods=[POST],consumes=[application/vnd.spring-boot.actuator.v1+json || application/json],produces=[application/vnd.spring-boot.actuator.v1+json || application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.LoggersMvcEndpoint.set(java.lang.String,java.util.Map<java.lang.String, java.lang.String>)
    2017-09-13 10:07:11.434  INFO 8184 --- [           main] o.s.b.a.e.mvc.EndpointHandlerMapping     : Mapped "{[/loggers || /loggers.json],methods=[GET],produces=[application/vnd.spring-boot.actuator.v1+json || application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
    2017-09-13 10:07:11.435  INFO 8184 --- [           main] o.s.b.a.e.mvc.EndpointHandlerMapping     : Mapped "{[/env/{name:.*}],methods=[GET],produces=[application/vnd.spring-boot.actuator.v1+json || application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EnvironmentMvcEndpoint.value(java.lang.String)
    2017-09-13 10:07:11.436  INFO 8184 --- [           main] o.s.b.a.e.mvc.EndpointHandlerMapping     : Mapped "{[/env || /env.json],methods=[GET],produces=[application/vnd.spring-boot.actuator.v1+json || application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
    2017-09-13 10:07:11.437  INFO 8184 --- [           main] o.s.b.a.e.mvc.EndpointHandlerMapping     : Mapped "{[/configprops || /configprops.json],methods=[GET],produces=[application/vnd.spring-boot.actuator.v1+json || application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
    2017-09-13 10:07:11.438  INFO 8184 --- [           main] o.s.b.a.e.mvc.EndpointHandlerMapping     : Mapped "{[/mappings || /mappings.json],methods=[GET],produces=[application/vnd.spring-boot.actuator.v1+json || application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
    2017-09-13 10:07:11.441  INFO 8184 --- [           main] o.s.b.a.e.mvc.EndpointHandlerMapping     : Mapped "{[/health || /health.json],methods=[GET],produces=[application/vnd.spring-boot.actuator.v1+json || application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.HealthMvcEndpoint.invoke(javax.servlet.http.HttpServletRequest,java.security.Principal)
    2017-09-13 10:07:11.442  INFO 8184 --- [           main] o.s.b.a.e.mvc.EndpointHandlerMapping     : Mapped "{[/trace || /trace.json],methods=[GET],produces=[application/vnd.spring-boot.actuator.v1+json || application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
    2017-09-13 10:07:11.455  INFO 8184 --- [           main] o.s.b.a.e.mvc.EndpointHandlerMapping     : Mapped "{[/beans || /beans.json],methods=[GET],produces=[application/vnd.spring-boot.actuator.v1+json || application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
    2017-09-13 10:07:11.457  INFO 8184 --- [           main] o.s.b.a.e.mvc.EndpointHandlerMapping     : Mapped "{[/auditevents || /auditevents.json],methods=[GET],produces=[application/vnd.spring-boot.actuator.v1+json || application/json]}" onto public org.springframework.http.ResponseEntity<?> org.springframework.boot.actuate.endpoint.mvc.AuditEventsMvcEndpoint.findByPrincipalAndAfterAndType(java.lang.String,java.util.Date,java.lang.String)
    2017-09-13 10:07:11.458  INFO 8184 --- [           main] o.s.b.a.e.mvc.EndpointHandlerMapping     : Mapped "{[/heapdump || /heapdump.json],methods=[GET],produces=[application/octet-stream]}" onto public void org.springframework.boot.actuate.endpoint.mvc.HeapdumpMvcEndpoint.invoke(boolean,javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse) throws java.io.IOException,javax.servlet.ServletException
    2017-09-13 10:07:11.459  INFO 8184 --- [           main] o.s.b.a.e.mvc.EndpointHandlerMapping     : Mapped "{[/autoconfig || /autoconfig.json],methods=[GET],produces=[application/vnd.spring-boot.actuator.v1+json || application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
    2017-09-13 10:07:11.461  INFO 8184 --- [           main] o.s.b.a.e.mvc.EndpointHandlerMapping     : Mapped "{[/metrics/{name:.*}],methods=[GET],produces=[application/vnd.spring-boot.actuator.v1+json || application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.MetricsMvcEndpoint.value(java.lang.String)
    2017-09-13 10:07:11.461  INFO 8184 --- [           main] o.s.b.a.e.mvc.EndpointHandlerMapping     : Mapped "{[/metrics || /metrics.json],methods=[GET],produces=[application/vnd.spring-boot.actuator.v1+json || application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
    2017-09-13 10:07:11.462  INFO 8184 --- [           main] o.s.b.a.e.mvc.EndpointHandlerMapping     : Mapped "{[/dump || /dump.json],methods=[GET],produces=[application/vnd.spring-boot.actuator.v1+json || application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
    2017-09-13 10:07:12.215  INFO 8184 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Registering beans for JMX exposure on startup
    2017-09-13 10:07:12.265  INFO 8184 --- [           main] o.s.c.support.DefaultLifecycleProcessor  : Starting beans in phase 0
    2017-09-13 10:07:12.508  INFO 8184 --- [           main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 8080 (http)
    2017-09-13 10:07:12.516  INFO 8184 --- [           main] com.didispace.DemoApplication            : Started DemoApplication in 6.135 seconds (JVM running for 6.507)
    2017-09-13 10:07:15.814  INFO 8184 --- [nio-8080-exec-1] o.apache.tomcat.util.http.parser.Cookie  : A cookie header was received [1504835114,1504853870,1504921477; userName=15502178001; CNZZDATA1259588364=1749552444-1504923593-%7C1504923593; Hm_lvt_52e5a18a3acfbe8cbcaf0e5310c71960=1505008163; _jzqa=1.3321994716853817000.1504512626.1504512626.1504925890.2; _jzqx=1.1504925890.1504925890.1.jzqsr=localhost|jzqct=/sso/logout%2Ehtm.-] that contained an invalid cookie. That cookie will be ignored.Note: further occurrences of this error will be logged at DEBUG level.
    2017-09-13 10:07:15.819  INFO 8184 --- [nio-8080-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring FrameworkServlet 'dispatcherServlet'
    2017-09-13 10:07:15.819  INFO 8184 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : FrameworkServlet 'dispatcherServlet': initialization started
    2017-09-13 10:07:15.837  INFO 8184 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : FrameworkServlet 'dispatcherServlet': initialization completed in 18 ms
    2017-09-13 10:07:15.870  INFO 8184 --- [nio-8080-exec-1] ication$$EnhancerBySpringCGLIB$$eb18da0a : Logger Level :INFO
    2017-09-13 10:07:15.870 ERROR 8184 --- [nio-8080-exec-1] ication$$EnhancerBySpringCGLIB$$eb18da0a : Logger Level :ERROR
    2017-09-13 10:07:15.884 ERROR 8184 --- [nio-8080-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet]    : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is java.lang.IllegalArgumentException: An invalid domain [.ebways.com] was specified for this cookie] with root cause
    
    java.lang.IllegalArgumentException: An invalid domain [.ghsau.com] was specified for this cookie
        at org.apache.tomcat.util.http.Rfc6265CookieProcessor.validateDomain(Rfc6265CookieProcessor.java:183) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
        at org.apache.tomcat.util.http.Rfc6265CookieProcessor.generateHeader(Rfc6265CookieProcessor.java:125) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
        at org.apache.catalina.connector.Response.generateCookieString(Response.java:989) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
        at org.apache.catalina.connector.Response.addCookie(Response.java:937) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
        at org.apache.catalina.connector.ResponseFacade.addCookie(ResponseFacade.java:386) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
        at com.didispace.DemoApplication.testLogLevel(DemoApplication.java:32) ~[classes/:na]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.7.0_75]
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[na:1.7.0_75]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.7.0_75]
        at java.lang.reflect.Method.invoke(Method.java:606) ~[na:1.7.0_75]
        at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205) ~[spring-web-4.3.7.RELEASE.jar:4.3.7.RELEASE]
        at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:133) ~[spring-web-4.3.7.RELEASE.jar:4.3.7.RELEASE]
        at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:116) ~[spring-webmvc-4.3.7.RELEASE.jar:4.3.7.RELEASE]
        at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:827) ~[spring-webmvc-4.3.7.RELEASE.jar:4.3.7.RELEASE]
        at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:738) ~[spring-webmvc-4.3.7.RELEASE.jar:4.3.7.RELEASE]
        at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85) ~[spring-webmvc-4.3.7.RELEASE.jar:4.3.7.RELEASE]
        at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:963) ~[spring-webmvc-4.3.7.RELEASE.jar:4.3.7.RELEASE]
        at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:897) ~[spring-webmvc-4.3.7.RELEASE.jar:4.3.7.RELEASE]
        at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970) ~[spring-webmvc-4.3.7.RELEASE.jar:4.3.7.RELEASE]
        at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:861) ~[spring-webmvc-4.3.7.RELEASE.jar:4.3.7.RELEASE]
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:622) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
        at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846) ~[spring-webmvc-4.3.7.RELEASE.jar:4.3.7.RELEASE]
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:729) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:230) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
        at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) ~[tomcat-embed-websocket-8.5.11.jar:8.5.11]
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
        at org.springframework.boot.web.filter.ApplicationContextHeaderFilter.doFilterInternal(ApplicationContextHeaderFilter.java:55) ~[spring-boot-1.5.2.RELEASE.jar:1.5.2.RELEASE]
        at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-4.3.7.RELEASE.jar:4.3.7.RELEASE]
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
        at org.springframework.boot.actuate.trace.WebRequestTraceFilter.doFilterInternal(WebRequestTraceFilter.java:108) ~[spring-boot-actuator-1.5.2.RELEASE.jar:1.5.2.RELEASE]
        at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-4.3.7.RELEASE.jar:4.3.7.RELEASE]
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
        at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99) ~[spring-web-4.3.7.RELEASE.jar:4.3.7.RELEASE]
        at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-4.3.7.RELEASE.jar:4.3.7.RELEASE]
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
        at org.springframework.web.filter.HttpPutFormContentFilter.doFilterInternal(HttpPutFormContentFilter.java:105) ~[spring-web-4.3.7.RELEASE.jar:4.3.7.RELEASE]
        at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-4.3.7.RELEASE.jar:4.3.7.RELEASE]
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
        at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:81) ~[spring-web-4.3.7.RELEASE.jar:4.3.7.RELEASE]
        at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-4.3.7.RELEASE.jar:4.3.7.RELEASE]
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
        at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:197) ~[spring-web-4.3.7.RELEASE.jar:4.3.7.RELEASE]
        at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-4.3.7.RELEASE.jar:4.3.7.RELEASE]
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
        at org.springframework.boot.actuate.autoconfigure.MetricsFilter.doFilterInternal(MetricsFilter.java:106) ~[spring-boot-actuator-1.5.2.RELEASE.jar:1.5.2.RELEASE]
        at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-4.3.7.RELEASE.jar:4.3.7.RELEASE]
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96) [tomcat-embed-core-8.5.11.jar:8.5.11]
        at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:474) [tomcat-embed-core-8.5.11.jar:8.5.11]
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140) [tomcat-embed-core-8.5.11.jar:8.5.11]
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79) [tomcat-embed-core-8.5.11.jar:8.5.11]
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87) [tomcat-embed-core-8.5.11.jar:8.5.11]
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:349) [tomcat-embed-core-8.5.11.jar:8.5.11]
        at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:783) [tomcat-embed-core-8.5.11.jar:8.5.11]
        at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) [tomcat-embed-core-8.5.11.jar:8.5.11]
        at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:798) [tomcat-embed-core-8.5.11.jar:8.5.11]
        at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1434) [tomcat-embed-core-8.5.11.jar:8.5.11]
        at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) [tomcat-embed-core-8.5.11.jar:8.5.11]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [na:1.7.0_75]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [na:1.7.0_75]
        at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-embed-core-8.5.11.jar:8.5.11]
        at java.lang.Thread.run(Thread.java:745) [na:1.7.0_75]

    代码:

    @RestController
    @SpringBootApplication
    public class DemoApplication {
    
        private Logger logger = LoggerFactory.getLogger(getClass());
    
        @RequestMapping(value = "/test", method = RequestMethod.GET)
        public String testLogLevel(HttpServletRequest request, HttpServletResponse response) {
    
            logger.debug("Logger Level :DEBUG");
            logger.info("Logger Level :INFO");
            logger.error("Logger Level :ERROR");
    
            Cookie cookie2 = new Cookie("ERRRRR", "teststst");
            cookie2.setPath("/");
            cookie2.setDomain(".ghsau.com");
            cookie2.setMaxAge(3600);
            response.addCookie(cookie2);
    
            return "TEST";
        }
    
        public static void main(String[] args) {
            SpringApplication.run(DemoApplication.class, args);
        }
    }

    然后访问就报错,无法设置domain:

    Rfc6265CookieProcessor.java类:

    此处解决:

    使用 LegacyCookieProcessor即可解决。协议换了

    增加:

    @Bean
        public EmbeddedServletContainerCustomizer cookieProcessorCustomizer() {
            return new EmbeddedServletContainerCustomizer() {
    
                @Override
                public void customize(ConfigurableEmbeddedServletContainer container) {
                    if (container instanceof TomcatEmbeddedServletContainerFactory) {
                        ((TomcatEmbeddedServletContainerFactory) container)
                                .addContextCustomizers(new TomcatContextCustomizer() {
    
                                    @Override
                                    public void customize(Context context) {
                                        context.setCookieProcessor(new LegacyCookieProcessor());
                                    }
    
                                });
                    }
                }
    
            };
        }

    即可解决问题。

    Spring Boot使用的内嵌Tomcat不能开箱即用的支持Version 0的Cookie格式,你可能会看到以下错误:

    java.lang.IllegalArgumentException: An invalid character [32] was present in the Cookie value
    

    可以的话,你需要考虑将代码升级到只存储遵从最新版Cookie定义的值。如果不能改变写入的cookie,你可以配置Tomcat使用LegacyCookieProcessor。通过向EmbeddedServletContainerCustomizer bean添加一个TomcatContextCustomizer可以开启LegacyCookieProcessor

    参考:

    1、https://stackoverflow.com/questions/29608550/tomcat-cookie-domain-validation

    2、http://blog.didispace.com/books/spring-boot-reference/IX.%20%E2%80%98How-to%E2%80%99%20guides/70.10%20Use%20Tomcat%E2%80%99s%20LegacyCookieProcessor.html

  • 相关阅读:
    【vim使用】光标的 段落切换、括号切换
    【vim使用】行数跳转 和 屏幕移动
    【vim使用】vim的三种工作模式
    【vim使用】vim的异常处理,删除交换文件
    【vim使用】打开文件,并且定位行
    【vim使用】vim新建文件、打开文件
    【vim使用】vim简介
    【终端使用】SSH免密码登录——02
    【终端使用】SSH免密码登录——01
    【终端使用】"apt"命令 安装/卸载软件
  • 原文地址:https://www.cnblogs.com/gmq-sh/p/7513992.html
Copyright © 2020-2023  润新知