路由添加cookie处理程序。
router.route().handler(CookieHandler.create());
操作cookie
使用getCookie获取cookie.
删除用removeCookie.
添加addCookie.
添加cookie后会自动写回响应中。
例如
router.route().handler(CookieHandler.create()); router.route("some/path/").handler(routingContext -> { Cookie someCookie = routingContext.getCookie("mycookie"); String cookieValue = someCookie.getValue(); // Do something with cookie... // Add a cookie - this will get written back in the response automatically routingContext.addCookie(Cookie.cookie("othercookie", "somevalue")); });