springboot中怎样写cookie
3 回答
梦里花落0921
TA贡献1772条经验 获得超5个赞
请求获取了HttpServletRequest
1234567891011121314151617181920 | /** * @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 ; } |
添加回答
举报
0/150
提交
取消