java.lang.IllegalArgumentException:无效的cookie名称 - 值对

时间:2017-07-13 13:44:29

标签: java cookies javafx webengine

我在Java中的WebEngine中遇到了一个问题。当我尝试打开指定的URL时,我收到了异常:

lip 13, 2017 3:18:25 PM com.sun.webkit.network.URLLoader doRun
    WARNING: Unexpected error
    java.lang.IllegalArgumentException: Invalid cookie name-value pair
        at java.net.HttpCookie.parseInternal(HttpCookie.java:823)
        at java.net.HttpCookie.parse(HttpCookie.java:202)
        at java.net.HttpCookie.access$100(HttpCookie.java:58)
        at java.net.HttpCookie$12.parse(HttpCookie.java:977)
        at sun.net.www.protocol.http.HttpURLConnection.filterHeaderField(HttpURLConnection.java:2927)
        at sun.net.www.protocol.http.HttpURLConnection.getFilteredHeaderFields(HttpURLConnection.java:2964)
        at sun.net.www.protocol.http.HttpURLConnection.getHeaderFields(HttpURLConnection.java:3008)
        at sun.net.www.protocol.https.HttpsURLConnectionImpl.getHeaderFields(HttpsURLConnectionImpl.java:283)
        at com.sun.webkit.network.URLLoader.extractHeaders(URLLoader.java:988)
        at com.sun.webkit.network.URLLoader.didReceiveResponse(URLLoader.java:765)
        at com.sun.webkit.network.URLLoader.receiveResponse(URLLoader.java:497)
        at com.sun.webkit.network.URLLoader.doRun(URLLoader.java:164)
        at com.sun.webkit.network.URLLoader.lambda$run$98(URLLoader.java:129)
        at java.security.AccessController.doPrivileged(Native Method)
        at com.sun.webkit.network.URLLoader.run(URLLoader.java:128)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:748)

它会导致网页出错。我需要打开这个URL。在Firefox或Chrome中,一切都是正确的。如何解决?

1 个答案:

答案 0 :(得分:0)

我在JavaFX WebView

中加载自定义HTML页面时遇到了同样的错误
  

2017年12月3日下午8:37:26 com.sun.webkit.network.URLLoader doRun   警告:java.lang.IllegalArgumentException:cookie出现意外错误   版本应为0或1

这解决了我的问题。

java.net.CookieHandler.setDefault(null);

希望这对你有帮助。