public static Cookie getCookie(HttpServletRequest request, String cookieName) {
        if (cookieName == null || request == null) {
            return null;
        }
        Cookie[] cks = request.getCookies();
        if (cks == null) {
            return null;
        }
        for (Cookie cookie : cks) {
            if (cookieName.equals(cookie.getName())) {
                return cookie;
            }
        }
        return null;
    }
public static Cookie getCookie ( HttpServletRequest request , String cookieName ) { if ( cookieName == null || request == null ) { return null ; } Cookie [ ] cks = request . getCookies ( ) ; if ( cks == null ) { return null ; } for ( Cookie cookie : cks ) { if ( cookieName . equals ( cookie . getName ( ) ) ) { return cookie ; } } return null ; }
获取cookie

@param request
请求request
@param cookieName
cookie名
@return cookie