1.设置host
???127.0.0.1 ??????cookie1.ivy.com ???127.0.0.1 ??????cookie2.ivy.com ???127.0.0.1 ??????ivy.com
2.应用Cookie2的controller.(实际可以直接浏览器查看Cookie)
@RestControllerpublic class HelloController { ???@GetMapping("hello") ???public String sayHello(HttpServletRequest request) { ???????System.out.println("Cookie:"); ???????Cookie[] cookies = request.getCookies(); ???????if (cookies != null) { ???????????Arrays.asList(request.getCookies()).forEach(item -> { ???????????????System.out.print("key:" + item.getName() + "-" + "value:" + item.getValue() + "-" + "domain:" + item.getDomain() + "-" + "path:" + item.getPath() + "-" + "maxAge:" + item.getMaxAge()); ???????????????System.out.println(); ???????????}); ???????} ???????return "hello"; ???}}
http的Cookie(三.path)
原文地址:https://www.cnblogs.com/itivy/p/9981017.html