找了找了资料鉴定是cookie存储中文时报的异常。。
可先把存储的中文用utf-8编码一下。。
编码:title=URLEncoder.encode(title,"utf-8");
解码:title=URLDecoder.decode(title, "UTF-8");
<%
request.setCharacterEncoding("utf-8");
System.out.println("GetUser: "+request.getParameter("user"));
String user=URLEncoder.encode(request.getParameter("user"),"utf-8");
Cookie cookie=new Cookie("mrCookie",user+"#"+new Date().toLocaleString()); //本地时间有中文,所以又挂了
cookie.setMaxAge(15);
System.out.println("user:"+user+"; Cookie:"+cookie.getValue());
response.addCookie(cookie);
%>
本文介绍了一种解决Cookie中存储中文字符导致异常的方法,通过使用UTF-8编码和解码来确保中文字符能够正确地存储和读取。
2075

被折叠的 条评论
为什么被折叠?



