Servlet Cookie Add the return of 500

  • In the Servlet learning, when learning of Cookie, Cookie is added to the response, the results appear Error 500
Cookie cookie1 = new Cookie(COOKIE_NAME,new Date().toLocaleString());
  • Appears on this line of code
  • Upon inquiry it should be caused by coding problems.
  • We need to be encoded
Cookie cookie = new Cookie(COOKIE_NAME, URLEncoder.encode(new Date().toLocaleString(),"UTF-8"));
  • Cookie time required to obtain decoded
URLDecoder.decode(cookie.getValue(),"UTF-8") ;

Guess you like

Origin www.cnblogs.com/liyiran/p/11081767.html