cookieutils.java
来自「jsp 应用开发技术光盘 是《jsp应用开发技术》这本书的源代码」· Java 代码 · 共 38 行
JAVA
38 行
/*
* Created on 2005-7-19
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
package ch08;
import javax.servlet.http.*;
/**
* @author 赵长海
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
*/
public class CookieUtils {
public static String getCookieValue(Cookie[] cookies,String cookieName,String defaultValue) {
for(int i=0; i<cookies.length; i++) {
Cookie cookie = cookies[i];
if (cookieName.equals(cookie.getName()))
return(cookie.getValue());
}
return(defaultValue);
}
public static Cookie getCookie(Cookie[] cookies,String cookieName) {
for(int i=0; i<cookies.length; i++) {
Cookie cookie = cookies[i];
if (cookieName.equals(cookie.getName()))
return(cookie);
}
return(null);
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?