使用Java中的PlayFramework,我想记录Play可以读取的所有cookie名称的列表。
我尝试调用,request().cookies()
但它不是List,它是一个对象,并且此对象中没有List。
我可以打电话,request().cookie(String name);
但是这希望我知道Cookie的名称,但我不知道。
那我该怎么办?
这是我刚提出的解决方案,我不知道它是否是最好的,但是它可以工作:
for (String cookieStr : request.headers().get("Cookie")) {
String name = cookieStr.substring(0, cookieStr.indexOf("="));
Logger.info("Name of the cookie : " + name);
Cookie cookie = request.cookie(name); // Get the instance of the cookie !
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句