0

我在 Java 中的 WebEngine 中的 cookie 有问题。当我尝试打开指定的 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 中一切正常。如何解决?

4

1 回答 1

0

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

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

这为我解决了这个问题。

java.net.CookieHandler.setDefault(null);

希望这对您也有帮助。

于 2017-12-03T14:53:13.957 回答