0
将三个cookie从servlet发送到客户端,并输入表单中的条目,名称的年龄和姓氏以及用户输入的值。读取cookie值并将它们存储在适当的变量中
当客户端发送回饼干服务器我必须存储:
-
在字符串变量名
- 在int变量年龄的值命名为“名”
- 的cookie的值该cookie命名为“年龄”
- 在thestring变量名命名为“姓”的cookie的值
我已经写了这一点,但它不是编译,我不知道为什么:
Cookie cookies[] = request.getCookies();
String name;整年龄;字符串姓氏;
for (int i=0; i<cookies.lenght; i++) {
如果(饼干[I] .getName()。等于( “名字”))
name=cookies[i].getValue;
否则,如果(饼干[I] .getName()。等于( “时代”) )
age=cookies[i].getValue;
否则,如果(饼干[I] .getName()。等于( “姓”))
surname=cookies[i].getValue;
有3个错误:
error: cannot find symbol name=cookies[i].getValue; symbol: variable getValue location: class Cookie
error: cannot find symbol age=cookies[i].getValue; location:class Cookie
error: cannot find symbol surname=cookies[i].getValue; symbol: variable getValue location: class Cookie
真的不知道该如何谢谢。非常感谢你。你救了我。我试图解决这个问题的时间是两个小时。 – user3498731