码迷,mamicode.com
首页 > Web开发 > 详细

http的Cookie(三.path)

时间:2018-11-19 00:49:36      阅读:168      评论:0      收藏:0      [点我收藏+]

标签:main   public   复制   for   path   ping   .com   int   toolbar   

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)

技术分享图片
@RestController
public 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)

标签:main   public   复制   for   path   ping   .com   int   toolbar   

原文地址:https://www.cnblogs.com/itivy/p/9981017.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!