继续浏览精彩内容
慕课网APP
程序员的梦工厂
打开
继续
感谢您的支持,我会继续努力的
赞赏金额会直接到老师账户
将二维码发送给自己后长按识别
微信支付
支付宝支付

Cookie 异常字符问题

阿西莫夫
关注TA
已关注
手记 4
粉丝 1
获赞 6

严重: Servlet.service() for servlet [jsp] in context with path [/JspViewListDemo] threw exception [An exception occurred processing [details.jsp] at line [70]

67: }
68: }
69: Cookie cookie = new Cookie("ListViewCookie",list);
70: response.addCookie(cookie);
71:
72: %>
73: <!-- 浏览过的商品 -->
Stacktrace:] with root cause
java.lang.IllegalArgumentException: An invalid character [44] was present in the Cookie value

https://www.imooc.com/qadetail/177191

list+=request.getParameter("id")+"#";
//如果浏览记录超过1000条,清零.
String[] arr = list.split("#");
if(arr!=null&&arr.length>0)
{
if(arr.length>=1000)
{
list="";
}
}
Cookie cookie = new Cookie("ListViewCookie",list);
response.addCookie(cookie);
将逗号,换成#,记得itemdao的方法也是

打开App,阅读手记
0人推荐
发表评论
随时随地看视频慕课网APP