java後臺獲取cookie

萬年精魄發表於2018-04-25
Cookie[] cookies = request.getCookies();
String token = "";
for (Cookie cookie : cookies) {
    switch(cookie.getName()){
        case "token":
            token = cookie.getValue();
            break;
        default:
            break;
    }
}

java後臺從request獲取cookie,獲取的應該是一個陣列,通過遍歷陣列來獲取我們需要的值;

相關文章