服务器端得到cookie


1.
getname 获取key getvalue 获取值


Cookie[] cookie = request.getCookies();

response.getWriter().write("cookie获取成功!");
for(Cookie cookie1:cookie)
{
response.getWriter().write(cookie1.getName()+cookie1.getValue()+cookie1.getPath());
}

当我们想要得到某个cookie的时候 可以将其封装成一个工具类
Cookie IwantCookie=null;
if("key".equals(cookie1.getName())){
IwantCookie=cookie1;
response.getWriter().write(IwantCookie.getValue()+"</br>");
}
if(IwantCookie!=null)
System.out.println("找到了");


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM