摘要:
首先写一个过滤器的类,如下: 1 package com.util; 2 3 import java.io.IOException; 4 import java.io.UnsupportedEncodingException; 5 6 import javax.servlet.Filter; 7 import javax.servlet.FilterChain; 8 import javax.servlet.FilterConfig; 9 import javax.servlet.ServletException;10 import javax.servlet.ServletRequest.. 阅读全文
摘要:
写cookie Cookie cookie = new Cookie("username", java.net.URLEncoder.encode(username,"UTF-8")); cookie.setMaxAge(50*60);//不设置的话,则cookies不写入硬盘,而是写在内存,只在当前页面有用,以秒为单位 response.addCookie(cookie);读cookieCookie cookies[] = request.getCookies(); if (cookies != null) { for (int i = 0; i &l 阅读全文