使用 PlayFramework(Java 语言),我想记录 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 !
}
关于java - 如何在 Play 中列出 cookie,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17544109/