当前位置:网站首页>Servlet用Cookie实现用户上次登录时间
Servlet用Cookie实现用户上次登录时间
2022-07-27 14:51:00 【TDSSS】
问题:遇到异常
An invalid character [32] was present in the Cookie value
原因:
在格式化时间的时候出现了空格,cookie的值里不允许包含空格
// 获取当前时间
long currentTimeMillis = System.currentTimeMillis();
String pattern = "yyyy-MM-dd HH:mm:ss";
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern, Locale.getDefault());
String time = simpleDateFormat.format(currentTimeMillis);解决办法:
给客户端发送cookie时把时间进行utf-8编码,用的时候解码即可
// 把time进行编码
time = URLEncoder.encode(time, "utf-8");//把从cookie中拿到的时间解码
value = URLDecoder.decode(value, "utf-8");边栏推荐
- Thesis reduction
- Cubemx联合IAR工程移植
- codis集群部署
- Reduce PDF document size (Reprint)
- ADAMS中转动整个模型
- 获取当前时间的前N天和前后天的数组列表循环遍历每一天
- 使用百度飞桨EasyDL实现电商UGC图片自动分类
- The 31st --- the 52nd
- [paper reading] single- and cross modality near duplicate image pairsdetection via spatial transformer compare
- 自然排序:comparable接口,定制排序:compartor接口的区别
猜你喜欢

CDQ divide and conquer and whole dichotomy learning notes

solidwork装配体导入到Adams中出现多个Part重名和Part丢失的情况处理

收藏!0基础开源数据可视化平台FlyFish大屏开发指南

OpenCV(三)——图像分割

使用百度飞桨EasyDL实现电商UGC图片自动分类

HowNet and Wanfang database download papers for free ----- several times faster than connecting to the school intranet (some schools Wanfang database does not support downloading)

Simulation generate report

ShardingSphere-proxy-5.0.0分布式雪花ID生成(三)

Collection! 0 basic open source data visualization platform flyfish large screen development guide

As changes the background theme and background picture
随机推荐
training on multiple GPUs pytorch
嵌入式面试
The 21st - -- the 30th time
Replication of complex linked list
String numeric type converted to thousands
t5 学习
Json数据的格式使用
知网、万方数据库免费下载论文------比连接学校内网速度快数倍不止(有的学校万方数据库不支持下载)
excel skill
Life game, universe 25 and striver
android中的图片三级缓存
京东张政:内容理解在广告场景下的实践和探索
Cvxpy - latest issue
实测:云RDS MySQL性能是自建的1.6倍
Const summary
MySQL high version report SQL_ mode=only_ full_ group_ By exception
Gurobi——GRBEnv
201403-1
MQ Series 2: technology selection of Message Oriented Middleware
Rotate the whole model in ADAMS