cookie教程问题
http://www.hccp.org/java-net-cookie-how -to.html
根据此链接,我试图创建 cookie 并发送 cookie 以进入 cookie 站点。但它不起作用。这里面有没有什么问题呢。我对 URLConnection
的方法 setRequestProperty
有一些困惑。我不明白他们试图通过传递“Cookie”
来发送什么?它只是一个字符串、名称或值吗?
http://www.hccp.org/java-net-cookie-how-to.html
According to this link I was trying to create cookie and send cookie to enter in a cookie site. But it is not working. Is there is any problem in that. I have some confusion on the method setRequestProperty
of URLConnection
. I don't understand what are they trying to send by passing "Cookie"
? Is it only a string or name or value??
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在本例中,
"Cookie"
是一种告诉setRequestProperty
方法参数(实际上只是一个String
)应该被视为一块饼干。setRequestProperty
对于多种属性可能更有用,但是addRequestProperty
会更多对于 cookie 很有用,因为每个请求可以有多个 cookie。这些属性在 RFC 2068 中指定 - 特别阅读第 14 节。"Cookie"
in this case is a way to tell thesetRequestProperty
method that the argument (which is really just aString
) should be treated as a cookie.setRequestProperty
may be more useful for many kinds of properties, butaddRequestProperty
would be more useful for cookies, because you can have multiple cookies per request. The properties are specified in RFC 2068 -- read especially section 14.