当前位置: 首页>>代码示例>>Java>>正文


Java Cookie.getValue方法代码示例

本文整理汇总了Java中javax.servlet.http.Cookie.getValue方法的典型用法代码示例。如果您正苦于以下问题:Java Cookie.getValue方法的具体用法?Java Cookie.getValue怎么用?Java Cookie.getValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.servlet.http.Cookie的用法示例。


在下文中一共展示了Cookie.getValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getValueByCookie

import javax.servlet.http.Cookie; //导入方法依赖的package包/类
private static String getValueByCookie(HttpServletRequest request, String name)
{
	Cookie cookies[] = request.getCookies();
	String value = null;
	if(cookies != null)
	{
		Cookie cookie = null;
		for(int i = 0; i < cookies.length; i++)
		{
			cookie = cookies[i];
			if(cookie.getName().equals(name))
			{
				value = cookie.getValue();
				break;
			}
		}
	}
	return value;
}
 
开发者ID:skeychen,项目名称:dswork,代码行数:20,代码来源:WebFilter.java

示例2: getValue

import javax.servlet.http.Cookie; //导入方法依赖的package包/类
/**
 * 根据cookie名称取得参数值
 * @param name cookie参数名
 * @return 存在返回String,不存在返回null
 */
public String getValue(String name)
{
	Cookie cookies[] = request.getCookies();
	String value = null;
	if(cookies != null)
	{
		Cookie cookie = null;
		for(int i = 0; i < cookies.length; i++)
		{
			cookie = cookies[i];
			if(cookie.getName().equals(name))
			{
				value = cookie.getValue();
				break;
			}
		}
	}
	return value;
}
 
开发者ID:skeychen,项目名称:dswork,代码行数:25,代码来源:MyCookie.java

示例3: findCookieByName

import javax.servlet.http.Cookie; //导入方法依赖的package包/类
/**
 * 获取指定cookies的值 findCookieByName
 * 
 * @param request
 * @param name
 * @return String
 */
public static String findCookieByName(HttpServletRequest request,
		String name) {
	Cookie[] cookies = request.getCookies();
	if(null == cookies || cookies.length == 0) return null;
	String string = null;
	try {
		for (int i = 0; i < cookies.length; i++) {
			Cookie cookie = cookies[i];
			String cname = cookie.getName();
			if (!StringUtils.isBlank(cname) && cname.equals(name)) {
				string = cookie.getValue();
			}

		}
	} catch (Exception ex) {
		logger.error("获取Cookies发生异常!", ex);
	}
	return string;
}
 
开发者ID:wjggwm,项目名称:webside,代码行数:27,代码来源:CookieUtil.java

示例4: getServerIdFromCookie

import javax.servlet.http.Cookie; //导入方法依赖的package包/类
/**
 * Locates any specification of which server that issued a
 * session. If there is no session or the session isn't mapped
 * to a specific server null is returned.
 * 
 * @param cookies The cookies so look for a session in
 * @return the server's ID or null if no server is found
 */
private String getServerIdFromCookie(Cookie[] cookies) {
    String serverId = null;
    if (cookies != null) {
        for (int i=0; i < cookies.length; i++) {
            Cookie cookie = cookies[i];
            if ( isSessionCookie(cookie.getName()) ) {
                String value = cookie.getValue();
                String id = value.substring(value.indexOf(".")+1);
                if (id.startsWith("server")) {
                    serverId = id;
                }
            }
        } 
    }
    return serverId;
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:25,代码来源:ClusterContainer.java

示例5: getCookie

import javax.servlet.http.Cookie; //导入方法依赖的package包/类
public String getCookie(HttpServletRequest request, String key) {
    Cookie[] cookies = request.getCookies();

    if (cookies == null) {
        return null;
    }

    for (Cookie cookie : cookies) {
        if ((cookie == null) || (cookie.getName() == null)) {
            continue;
        }

        if (cookie.getName().equals(key)) {
            return cookie.getValue();
        }
    }

    return null;
}
 
开发者ID:zhaojunfei,项目名称:lemon,代码行数:20,代码来源:DeviceFilter.java

示例6: getRequestedSessionId

import javax.servlet.http.Cookie; //导入方法依赖的package包/类
@Override
public String getRequestedSessionId(HttpServletRequest request) {
    Cookie[] cookies = request.getCookies();
    for (Cookie cookie : cookies) {
        if (cookie == null) {
            continue;
        }

        if (!COOKIE_NAME_SESSION.equalsIgnoreCase(cookie.getName())) {
            continue;
        }

        return cookie.getValue();
    }
    return null;
}
 
开发者ID:alexqdjay,项目名称:simple-session,代码行数:17,代码来源:CookieBasedTransaction.java

示例7: getCookie

import javax.servlet.http.Cookie; //导入方法依赖的package包/类
/**
 * 获取 cookie 的值
 * @param name 名称
 * @return
 */
public String getCookie(String name){
	Cookie[] cookies=request.getCookies();
	if(cookies != null && cookies.length >0){
		for(int i=0;i<cookies.length;i++){
			Cookie cookie=cookies[i];
			if(cookie.getName().equals(name) && cookie.getValue()!=null){
				try {
					return URLDecoder.decode(cookie.getValue(),"utf-8");
				} catch (UnsupportedEncodingException e) {
					e.printStackTrace();
				}
			}
		}
	}
	return null;
}
 
开发者ID:gooking,项目名称:yijava,代码行数:22,代码来源:CookieUtil.java

示例8: getToken

import javax.servlet.http.Cookie; //导入方法依赖的package包/类
public String getToken( HttpServletRequest request ) {
    /**
     *  Getting the token from Cookie store
     */
    Cookie authCookie = getCookieValueByName( request, AUTH_COOKIE );
    if ( authCookie != null ) {
        return authCookie.getValue();
    }
    /**
     *  Getting the token from Authentication header
     *  e.g Bearer your_token
     */
    String authHeader = request.getHeader(AUTH_HEADER);
    if ( authHeader != null && authHeader.startsWith("Bearer ")) {
        return authHeader.substring(7);
    }

    return null;
}
 
开发者ID:bfwg,项目名称:angular-spring-starter,代码行数:20,代码来源:TokenHelper.java

示例9: loadToken

import javax.servlet.http.Cookie; //导入方法依赖的package包/类
@Override
public CsrfTokenBean loadToken(HttpServletRequest request) {
	Cookie cookie = WebUtils.getCookie(request, this.cookieName);
	if (cookie == null) {
		return null;
	}
	String token = cookie.getValue();
	if (!StringUtils.hasLength(token)) {
		return null;
	}
	return new CsrfTokenBean(this.headerName, this.parameterName, token);
}
 
开发者ID:TomChen001,项目名称:xmanager,代码行数:13,代码来源:CookieCsrfTokenRepository.java

示例10: getToken

import javax.servlet.http.Cookie; //导入方法依赖的package包/类
/**
 * 从Request中获取token
 * @param request 请求体
 * @return token
 */
public String getToken(HttpServletRequest request) {
    Cookie authCookie = getCookieValue(request, jwtProperties.getAuthCookie());
    if (authCookie != null) {
        return authCookie.getValue();
    }
    String authHeader = request.getHeader(jwtProperties.getAuthHeader());
    if (authHeader != null && authHeader.startsWith("bearer ")) {
        return authHeader.substring(7);
    }
    return null;
}
 
开发者ID:YupaiTS,项目名称:docs-manage,代码行数:17,代码来源:JwtHelper.java

示例11: getCookie

import javax.servlet.http.Cookie; //导入方法依赖的package包/类
/**
 * 获取cookie
 * @param request
 * @param name
 * @return
 */
public static String getCookie(HttpServletRequest request, String name) {
    String value = null;
    Cookie[] cookies = request.getCookies();
    if (null != cookies) {
        for (Cookie cookie : cookies) {
            if (cookie.getName().equals(name)) {
                value = cookie.getValue();
            }
        }
    }
    return value;
}
 
开发者ID:ChangyiHuang,项目名称:shuzheng,代码行数:19,代码来源:CookieUtil.java

示例12: getUserNameInCookie

import javax.servlet.http.Cookie; //导入方法依赖的package包/类
public static String getUserNameInCookie(HttpServletRequest request) {
    Cookie[] cookies = request.getCookies();
    if (cookies != null)
        for (Cookie cookie : cookies)
            if (ATT_NAME_USER_NAME.equals(cookie.getName()))
                return cookie.getValue();
    return null;
}
 
开发者ID:biblelamp,项目名称:JavaEE,代码行数:9,代码来源:MyUtils.java

示例13: getCookieUid

import javax.servlet.http.Cookie; //导入方法依赖的package包/类
/**
 * 获取cookie中的用户id
 *
 * @param request
 * @return
 */
public static Integer getCookieUid(HttpServletRequest request) {
    if (null != request) {
        Cookie cookie = cookieRaw(WebConst.USER_IN_COOKIE, request);
        if (cookie != null && cookie.getValue() != null) {
            try {
                String uid = Tools.deAes(cookie.getValue(), WebConst.AES_SALT);
                return StringUtils.isNotBlank(uid) && Tools.isNumber(uid) ? Integer.valueOf(uid) : null;
            } catch (Exception e) {
            }
        }
    }
    return null;
}
 
开发者ID:ZHENFENG13,项目名称:My-Blog,代码行数:20,代码来源:TaleUtils.java

示例14: getCookieValue

import javax.servlet.http.Cookie; //导入方法依赖的package包/类
public static String getCookieValue(HttpServletRequest request, String cookieName) {
	Cookie[] cookies = request.getCookies();
	String k = null;
	if (cookies != null) {
		for (int i = 0; i < cookies.length; i++) {
			Cookie cookie = cookies[i];
			if (cookieName.equals(cookie.getName())) {
				k = (cookie.getValue());
			}
		}
	}
	return k;
}
 
开发者ID:181192,项目名称:DAT104,代码行数:14,代码来源:CookieUtil.java

示例15: getClientParameter

import javax.servlet.http.Cookie; //导入方法依赖的package包/类
/**
 * Returns status view selection, if any, based on
 * parameters, the session or the cookie.
 */
protected final String getClientParameter(final Parameters params, final HttpServletRequest request,
                                          final String parameterName, final String sessionParameterName,
                                          final String cookieName) {
  String result = params.getParameterValue(parameterName);
  if (!StringUtils.isBlank(result)) {
    return result;
  }

  result = request.getParameter(parameterName);
  if (!StringUtils.isBlank(result)) {
    return result;
  }

  final HttpSession session = request.getSession();
  result = (String) session.getAttribute(sessionParameterName);
  if (!StringUtils.isBlank(result)) {
    return result;
  }

  final Cookie[] cookies = request.getCookies();
  if (cookies != null) {
    for (int i = 0; i < cookies.length; i++) {
      final Cookie cookie = cookies[i];
      if (!StringUtils.isBlank(cookie.getName())
              && cookie.getName().equals(cookieName)
              && !StringUtils.isBlank(cookie.getValue())) {
        result = cookie.getValue();
        break;
      }
    }
  }
  return result;
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:38,代码来源:BasePage.java


注:本文中的javax.servlet.http.Cookie.getValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。