日化用品进货清单:jsp里怎么用request.getCookies()这个函数?

来源:百度文库 编辑:高校问答 时间:2024/04/30 02:32:18
Cookie[] allcookies=request.getCookies();
之后,我用
String idx=allcookies[0].getName();
可是它显示说
org.apache.jasper.JasperException: Exception in JSP: /cookie.jsp:20

19:
20: String idx=allcookies[0].getName();
21: String value=allcookies[0].getValue();
22: out.print(idx+":");
23: out.print(value+"<br>");
怎么着都不行,我想想没错呀?为什么呀???

加句话:
if(idx!=null)
然后再
19:
20: String idx=allcookies[0].getName();
21: String value=allcookies[0].getValue();
22: out.print(idx+":");
23: out.print(value+"<br>");
就可以了

request.getCookies(); 括号里应该加参数吧