• 在学习 Servlet 中,学习 Cookie 的时候,往 response 中添加 Cookie ,结果出现 500 的错误
Cookie cookie1 = new Cookie(COOKIE_NAME,new Date().toLocaleString());
  • 出现这行代码上
  • 经过查询应该是编码的问题造成的。
  • 需要进行编码
Cookie cookie = new Cookie(COOKIE_NAME, URLEncoder.encode(new Date().toLocaleString(),"UTF-8"));
  • 获取 Cookie 的时候需要解码
URLDecoder.decode(cookie.getValue(),"UTF-8") ;

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-01-14
  • 2021-10-03
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-25
猜你喜欢
  • 2022-12-23
  • 2022-02-05
  • 2021-11-27
  • 2022-12-23
  • 2021-07-28
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案