当前位置:网站首页>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");边栏推荐
- Codeforces Round #100 E. New Year Garland & 2021 CCPC Subpermutation
- 嵌入式面试
- Script file ‘D:\programs\anaconda3\Scripts\pip-script. py‘ is not present.
- Supplement - example of integer programming
- MySQL high version report SQL_ mode=only_ full_ group_ By exception
- 字节跳动服务网格基于 Hertz 框架的落地实践
- Crawl common English names
- Duplicate numbers in array
- Cubemx combined with IAR engineering transplantation
- 第21回---第30回
猜你喜欢

Simulation generate report

my_ Ls summary

Kubesphere multi node installation error

Gurobi——GRBLinExpr

低代码是开发的未来吗?浅谈低代码平台

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

清晰的认识Torchvision(思维导图版)

【论文阅读】A CNN-Transformer Hybrid Approach for CropClassification Using MultitemporalMultisensor Images

Insert pictures in word to maintain high DPI method

As changes the background theme and background picture
随机推荐
字符流读取文件
Cubemx联合IAR工程移植
jsp-El表达式,JSTL标签
Four solutions of maximum sub segment and go
[paper reading] a CNN transformer hybrid approach for coding visual neuralactivity into text
Casadi -- detailed explanation of data types and introduction to basic operations
Quadratic programming based on osqp
codis集群部署
gpt-2 文本生成
[paper reading] transformer with transfer CNN for remote sensing imageobject detection
File类字节输入、输出流
As changes the background theme and background picture
The difference between select/poll/epoll
Get the array list of the previous n days and the previous and subsequent days of the current time, and cycle through each day
Mazak handwheel maintenance Mazak little giant CNC machine tool handle operator maintenance av-eahs-382-1
JDBC程序实现完整步骤
The whereor method of TP5 has many conditions
Stylelint check error: unexpected missing generic font family font family no missing generic family keyword
Codeforces Round #100 E. New Year Garland & 2021 CCPC Subpermutation
Analysis of PHP keyword replacement classes (avoid repeated replacement, keep and restore the original links)