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"));
本文介绍了如何使用MD5进行加密,并探讨了在处理Cookie时中文存储的问题。通过结合System.currentTimeMillis()防止客户端缓存,确保每次请求的URL唯一,避免IE缓存导致的数据错误。同时,解释了Cookie的查找机制,从request、session到application,如果都找不到,则会抛出异常。
765

被折叠的 条评论
为什么被折叠?



