当前位置: 首页 > news >正文

Tomcat8服务器在Cookie中添加当前系统时间报错

错误信息:
HTTP Status 500 - An invalid character [32] was present in the Cookie value
type Exception report

message An invalid character [32] was present in the Cookie value

description The server encountered an internal error that prevented it from fulfilling this request.

exception

java.lang.IllegalArgumentException: An invalid character [32] was present in the Cookie value
org.apache.tomcat.util.http.Rfc6265CookieProcessor.validateCookieValue(Rfc6265CookieProcessor.java:162)
org.apache.tomcat.util.http.Rfc6265CookieProcessor.generateHeader(Rfc6265CookieProcessor.java:111)
org.apache.catalina.connector.Response.generateCookieString(Response.java:989)
org.apache.catalina.connector.Response.addCookie(Response.java:937)
org.apache.catalina.connector.ResponseFacade.addCookie(ResponseFacade.java:386)
CookieDemo.doGet(CookieDemo.java:26)
javax.servlet.http.HttpServlet.service(HttpServlet.java:622)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
note The full stack trace of the root cause is available in the Apache Tomcat/8.5.11 logs.

Apache Tomcat/8.5.11



部分Java代码为:

SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//设置日期格式Cookie lastCookie = new Cookie("lastCookie",df.format(new Date()));lastCookie.setMaxAge(3000);resp.addCookie(lastCookie);


解决方法:

将SimpleDateFormat df = new SimpleDateFormat(“yyyy-MM-dd HH:mm:ss”);代码中的空格替换为其他连接符(dd跟hh中间有空格


http://www.taodudu.cc/news/show-1476418.html

相关文章:

  • uniapp外部scss文件使用scss语法不生效,
  • [Python] datetime.strptime校验日期和时间的格式
  • Flutter 中的 GridTile 小部件:全面指南
  • GPT-4o:让你的应用拥有类人智慧
  • C++系统编程篇——Linux初识(系统安装、权限管理,权限设置)
  • 超声波清洗机哪个品牌好用?必选四款品质耐打的超声波清洗机分享
  • 动态代理 and Listener监听器
  • JQuery 高级
  • maven遇坑
  • Mybatis_day1
  • Mybatis注解配置与xml配置不能同时使用
  • Mybatis_day2_Mybatis的CRUD操作
  • Mybatis_day2_Mybatis的参数深入
  • Mybatis_day3_Mybatis的动态SQL
  • Mybatis_day3_Mybatis的多表查询
  • Mybatis_day4_Mybatis的延迟加载
  • Mybatis_day4_Mybatis的缓存
  • Mybatis_day4_Mybatis的注解开发
  • Mybatis遇坑
  • 关于java中的位运算
  • Spring_day1
  • Spring_day2
  • Spring_day3
  • Spring_day4
  • SpringMVC_day1
  • SpringMVC_day1_常用注解
  • SpringMVC_02
  • Error creating bean with name 'dataSource' defined in class path resource [spring/spring-dao.xml]:
  • SpringSecurity入门
  • 服务注册不进eureka
  • Spring Cloud总结
  • 在此之前的博客地址
  • golang利用反射写入excel的简单工具类
  • 实习工作难点记录
  • c 结构体之位域(位段)
  • 辗转相除求最大公约数,最大公倍数