java ee cookie方法键值对输出

<%@page import="java.net.URLDecoder"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<%

Cookie[] c =request.getCookies();

for(int i = 0; i < c.length; i++)
{
    out.print("名字是"+c[i].getName()
            +"value是"+URLDecoder.decode(c[i].getValue())+"<br>");
}

%>
</body>
</html>

键值对是数组类型,有键有值生成一个键值对,输出视为数组型可添加多个键值对。

posted @ 2016-06-30 10:38  薛岩  阅读(419)  评论(0编辑  收藏  举报