SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String nowTime = simpleDateFormat.format(new java.util.Date());
Cookie cookie = new Cookie("time",nowTime);
cookie.setMaxAge(3600);
response.addCookie(cookie);
为什么会报错???
An invalid character [32] was present in the Cookie value
cookie已经有值了
没有报错啊,这边运行OK啊
new Cookie("lastAccessTime",System.currentTimeMillis()+"");
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
就这行代码yyyy-MM-dd和HH:mm:ss中间有个空格就会错
如果这样
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-ddHH:mm:ss");
把yyyy-MM-dd和HH:mm:ss连着写就没有错了
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
就这行代码yyyy-MM-dd和HH:mm:ss中间有个空格就会错
如果这样
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-ddHH:mm:ss");
把yyyy-MM-dd和HH:mm:ss连着写就没有错了