/**
* 根据cookieName返回该cookie
* @param request
* @param cookieName
* @return
* @throws UnsupportedEncodingException
*/
public static Cookie getCookieByName(HttpServletRequest request,String cookieName) throws UnsupportedEncodingException{
Cookie[] cookies=request.getCookies();
if(cookies == null){
return null;
}
for(Cookie cookie:cookies){
if(cookie.getName().equals(cookieName)){
return new Cookie(cookie.getName(), URLDecoder.decode(cookie.getValue(), "UTF-8"));
}
}
return null;
}
根据cookieName返回该cookie
最新推荐文章于 2024-01-13 20:57:00 发布