跪求!!jsp中取cookie?
在jsp中如何取得单个cooike的值,是用cookie的关键字取,不是数组下标
用对象数组就不用说了,Cookie c[]=request.getCookies();这是取全部的然后用for(;;)对应每个c[]的下标取,这个谁都会。谢谢各位!
问题点数:40、回复次数:7Top
1 楼loginjava(清)回复于 2004-02-02 19:14:50 得分 5
帝Top
2 楼bighappy(简单)回复于 2004-02-02 20:02:12 得分 15
public static Cookie getCookie(HttpServletRequest request, String name) {
Cookie cookies[] = request.getCookies();
// Return null if there are no cookies or the name is invalid.
if(cookies == null || name == null || name.length() == 0) {
return null;
}
// Otherwise, we do a linear scan for the cookie.
for (int i = 0; i < cookies.length; i++) {
if(cookies[i].getName().equals(name) ) {
return cookies[i];
}
}
return null;
}Top
3 楼sunpowerkill(死亡动力)回复于 2004-02-02 20:58:29 得分 0
我倒了,兄弟们没有看到我写人吗,如果用for()取每个cookie人值我就不问了,我想用关键字,也就是cookie的标识为确定值的方法!!Top
4 楼minghui000(沉迷网络游戏)回复于 2004-02-03 02:01:26 得分 5
UPTop




