spring mvc 怎么获取cookie-CSDN论坛
展开全部
请求获取了HttpServletRequest
/**
* @param request
* @param cookieName
* @return
*/
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;
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询