/**
* Cookieの追加
* @return
* @throws Exception
*/
private void addCookie(String name,String value){
Cookie cookie = new Cookie(name, value);
cookie.setMaxAge(60*60*24*365);
ServletActionContext.getResponse().addCookie(cookie);
}
/**
* Cookieの取得
* @return
* @throws Exception
*/
private String getCookie(String name){
HttpServletRequest request = ServletActionContext.getRequest();
Cookie[] cookies = request.getCookies();
for(Cookie cookie : cookies)
{
if(cookie.getName().equals(name))
{
return cookie.getValue();
}
}
return null;
}
struts对cookie的存取
最新推荐文章于 2016-09-28 21:36:24 发布