springboot1.5.x使⽤tomcat8设置cookie的domain以dot开头报错
"C:\Program Files\Java\jdk1.7.0_75\bin\java" -XX:TieredStopAtLevel=1 -noverify -Dspring.abled=always "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA 2017.1.4\lib\idea_rt.jar=61656:C:\Program Files\JetBrains\IntelliJ IDEA 2  .  ____          _            __ _ _
/\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/  ___)| |_)| | | | | || (_| |  ) ) ) )
'  |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: 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:\workspaces\workspace_learning\SpringBo
ot-Learning\Chapter4-2-6\target\classe 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.t.embedded.AnnotationConfigEmbeddedWebApplicationContext@32a7c990: startup date [Wed Se 2017-09-13 10:07:09.295  INFO 8184 --- [          main] TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8080 (http)
2017-09-13 10:07:09.308  INFO 8184 --- [          main] o.StandardService  : Starting service Tomcat
2017-09-13 10:07:09.310  INFO 8184 --- [          main] org.StandardEngine  : Starting Servlet Engine: Apache Tomcat/8.5.11
2017-09-13 10:07:09.403  INFO 8184 --- [ost-startStop-1] C.[Tomcat].[localhost].[/]      : Initializing Spring embedded WebApplicationContext
2017-09-13 10:07:09.403  INFO 8184 --- [ost-startStop-1] o.t.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.a.RequestMappingHandlerAdapter : Looking for @ControllerAdvice: org.t.embedded.AnnotationConfigEmbeddedWebApplicationContext@32a7c990: s 2017-09-13 10:07:10.707  INFO 8184 --- [          main] s.a.RequestMappingHandlerMapping : Mapped "{[/test],methods=[GET]}" onto public java.lang.String com.stLogLevel(javax.servlet.http.HttpServletReq 2017-09-13 10:07:10.713  INFO 8184 --- [          main] s.a.RequestMappingHandlerMapping : Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframewo 2017-09-13 10:07:10.714  INFO 8184 --- [          main] s.a.RequestMappingHandlerMapping : Mapped "{[/error],produces=[text/html]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.w 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.source.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.source.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.source.ResourceHttpRequestHandler]
2017-09-13 10:07:11.430  INFO 8184 --- [          main] o.s.vc.EndpointHandlerMapping    : Mapped "{[/info || /info.json],methods=[GET],produces=[application/vnd.spring-boot.actuator.v1+json || application/json]}" onto public
2017-09-13 10:07:11.433  INFO 8184 --- [          main] o.s.vc.EndpointHandlerMapping    : Mapped "{[/loggers/{name:.*}],methods=[GET],produces=[application/vnd.spring-boot.actuator.v1+json || application/json]}" onto public
2017-09-13 10:07:11.434  INFO 8184 --- [          main] o.s.vc.EndpointHandlerMapping    : Mapped "{[/loggers/{name:.*}],methods=[POST],consumes=[application/vnd.spring-boot.actuator.v1+json || application/json],produces=[applicatio 2017-09-13 10:07:11.434  INFO 8184 -
-- [          main] o.s.vc.EndpointHandlerMapping    : Mapped "{[/loggers || /loggers.json],methods=[GET],produces=[application/vnd.spring-boot.actuator.v1+json || application/json]}" onto
2017-09-13 10:07:11.435  INFO 8184 --- [          main] o.s.vc.EndpointHandlerMapping    : Mapped "{[/env/{name:.*}],methods=[GET],produces=[application/vnd.spring-boot.actuator.v1+json || application/json]}" onto public java.lang.Obje 2017-09-13 10:07:11.436  INFO 8184 --- [          main] o.s.vc.EndpointHandlerMapping    : Mapped "{[/env || /env.json],methods=[GET],produces=[application/vnd.spring-boot.actuator.v1+json || application/json]}" onto public
2017-09-13 10:07:11.437  INFO 8184 --- [          main] o.s.vc.EndpointHandlerMapping    : Mapped "{[/configprops || /configprops.json],methods=[GET],produces=[application/vnd.spring-boot.actuator.v1+json || application/json]}" onto 2017-09-13 10:07:11.438  INFO 8184 --- [          main] o.s.vc.EndpointHandlerMapping    : Mapped "{[/mappings || /mappings.json],methods=[GET],produces=[application/vnd.spring-boot.actuator.v1+json || application/json]}" onto
2017-09-13 10:07:11.441  INFO 8184 --- [          main] o.s.vc.EndpointHandlerMapping    : Mapped "{[/health || /health.json],methods=[GET],produces=[application/vnd.spring-boot.actuator.v1+json || application/json]}" onto public
2017-09-13 10:07:11.442  INFO 8184 --- [          main] o.s.vc.EndpointHandlerMapping    : Mapped "{[/trace || /trace.json],methods=[GET],produces=[application/vnd.spring-boot.actuator.v1+json || application/json]}" onto public
2017-09-13 10:07:11.455  INFO 8184 --- [          main] o.s.vc.EndpointHandlerMapping    : Mapped "{[/beans || /beans.json],methods=[GET],produces=[application/vnd.spring-boot.actuator.v1+json || application/json]}" onto public
2017-09-13 10:07:11.457  INFO 8184 --- [          main] o.s.vc.EndpointHandlerMapping    : Mapped "{[/auditevents || /auditevents.json],methods=[GET],produces=[application/vnd.spring-boot.actuator.v1+json || application/json]}" onto 2017-09-13 10:07:11.458  INFO 8184 --- [          main] o.s.vc.EndpointHandlerMapping    : Mapped "{[/heapdump || /heapdump.json],methods=[GET],produces=[application/octet-stream]}" onto public void org.springframework.boot.actuat 2017-09-13 10:07:11.459  INFO 8184 --- [          main] o.s.vc.EndpointHandlerMapping    : Mapped "{[/autoconfig || /autoconfig.json],methods=[GET],produces=[application/vnd.spring-boot.actuator.v1+json || application/json]}" onto 2017-09-13 10:07:11.461  INFO 8184 --- [          main] o.s.vc.EndpointHandlerMapping    : Mapped "{[/metrics/{name:.*}],methods=[GET],produces=[application/vnd.spring-boot.actuator.v1+json || application/json]}" onto public
2017-09-13 10:07:11.461  INFO 8184 --- [          main] o.s.vc.EndpointHandlerMapping    : Mapped "{[/metrics || /metrics.json],methods=[GET],produces=[application/vnd.spring-boot.actuator.v1+json || application/json]}" onto
2017-09-13 10:07:11.462  INFO 8184 --- [          main] o.s.vc.EndpointHandlerMapping    : Mapped "{[/dump || /dump.json],methods=[GET],produces=[application/vnd.spring-boot.actuator.v1+json || application/json]}" onto public
2017-09-13 10:07:12.215  INFO 8184 --- [          main] o.a.AnnotationMBeanExporter        : Registering beans for JMX exposure on startup
2017-09-13 10:07:12.265  INFO 8184 --- [          main] support.DefaultLifecycleProcessor  : Starting beans in phase 0
2017-09-13 10:07:12.508  INFO 8184 --- [          main] 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] at.util.http.parser.Cookie  : A cookie header was received [1504835114,1504853870,1504921477; userName=155********; CNZZDATA1259588364=1749552444-15049235 2017-09-13 10:07:15.819  INFO 8184 --- [nio-8080-exec-1] 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] C.[.[.[/].[dispatcherServlet]    : S
ervlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is java.lang.Ill java.lang.IllegalArgumentException: An invalid domain [.ghsau] was specified for this cookie
at at.util.http.Rfc6265CookieProcessor.validateDomain(Rfc6265CookieProcessor.java:183) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
at at.util.ateHeader(Rfc6265CookieProcessor.java:125) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
at org.ateCookieString(Response.java:989) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
at org.tor.Response.addCookie(Response.java:937) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
at org.tor.ResponseFacade.addCookie(ResponseFacade.java:386) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
at com.stLogLevel(DemoApplication.java:32) ~[classes/:na]
flect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.7.0_75]
flect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[na:1.7.0_75]
flect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.7.0_75]
at flect.Method.invoke(Method.java:606) ~[na:1.7.0_75]
at org.hod.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205) ~[spring-web-4.3.7.RELEASE.jar:4.3.7.RELEASE]
at org.hod.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:133) ~[spring-web-4.3.7.RELEASE.jar:4.3.7.RELEASE]
at org.springframework.web.hod.annotation.ServletInvocableHandlerMethod.invokeA
ndHandle(ServletInvocableHandlerMethod.java:116) ~[spring-webmvc-4.3.7.RELEASE.jar:4.3.7.RELEASE]
at org.springframework.web.hod.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:827) ~[spring-webmvc-4.3.7.RELEASE.jar:4.3.7.RELEASE]
at org.springframework.web.hod.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:738) ~[spring-webmvc-4.3.7.RELEASE.jar:4.3.7.RELEASE]
at org.springframework.web.hod.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.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:230) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
at org.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
at at.websocket.server.WsFilter.doFilter(WsFilter.java:52) ~[tomcat-embed-websocket-8.5.11.jar:8.5.11]
at org.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
at org.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.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
at org.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
at org.springframework.ace.WebRequestTraceFilter.doFilterInternal(WebRequestTrac
eFilter.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.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
at org.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.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
at org.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.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
at org.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.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
at org.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.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
at org.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.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
at org.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
at org.StandardWrapperValve.invoke(StandardWrapperValve.java:198) ~[tomcat-embed-core-8.5.11.jar:8.5.11]    at org.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.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.StandardEngineValve.invoke(StandardEngineValve.java:87) [tomcat-embed-core-8.5.11.jar:8.5.11]
at org.tor.CoyoteAdapter.service(CoyoteAdapter.java:349) [tomcat-embed-core-8.5.11.jar:8.5.11]
at http11.Http11Processor.service(Http11Processor.java:783) [tomcat-embed-core-8.5.11.jar:8.5.11]
at AbstractProcessorLight.process(AbstractProcessorLight.java:66) [tomcat-embed-core-8.5.11.jar:8.5.11]
at AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:798) [tomcat-embed-core-8.5.11.jar:8.5.11]    at at.util.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1434) [tomcat-embed-core-8.5.11.jar:8.5.11]
at at.util.SocketProcessorBase.run(SocketProcessorBase.java:49) [tomcat-embed-core-8.5.11.jar:8.5.11]
at urrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [na:1.7.0_75]
at urrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [na:1.7.0_75]
at at.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 = Logger(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 Level :ERROR");
Cookie cookie2 = new Cookie("ERRRRR", "teststst");
cookie2.setPath("/");
cookie2.setDomain(".ghsau");
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() {
servlet和tomcat的关系@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
参考:

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。