标签:strong for ar amp new ad on sp
//写cookie
<form method="Get">
姓名:
<input type="text" name="name" />
<br />
<input type="submit" value="确定" />
</form>
<!-- 写入cookie到客户端 -->
<%
if (request.getParameter("name") != null
&& !request.getParameter("name").equals("")) {
String str=request.getParameter("name");
String value = URLEncoder.encode(str);
Cookie cookie = new Cookie("name", value);
response.addCookie(cookie);
}
%>
//读cookie
<%
request.setCharacterEncoding("utf-8");
Cookie myCookie[] = request.getCookies();
for (int i = 0; i < myCookie.length; i++) {
if (myCookie[i].getName().equals("name")) {
out.print(myCookie[i].getName() + ":"
+ URLDecoder.decode(myCookie[i].getValue()) + "<br>");
}
}
%>
Jsp---cookie中文乱码解决方法,布布扣,bubuko.com
标签:strong for ar amp new ad on sp
原文地址:http://www.cnblogs.com/beast-king/p/3920581.html