response.sendRedirect(request.getRequestURL()+”?”+System.currentTimeMillis());以毫秒为单位获取系统当前的时间,服务端防止客户端缓存的方法,让每一次url都是新的,防止它从ie的缓存中获取
相当于<{cookie.account.value}.
首先从request中查找,然后从session、application中查找,如果都查找不到就会报错。
//一个有中文内容的cookie
String str = "上海";
Cookie cookie = new Cookie("name",URLEncoder.encode(str,"UTF-8"));
response.addCookie(cookie);
//取出Cookie中的中文内容
Cookie[] cookies = request.getCookies();
String str = "";
for( int i=0; i <cookies.length;i++){
if(cookies[i].getName().equals("name")){
str = cookies[i].getValue();
}
}
out.println(URLDecoder.decode(str."UTF-8"));