簡體   English   中英

嘗試從HttpsURLConnection設置setPage()

[英]Trying to setPage() from a HttpsURLConnection


我試圖將頁面從HttpsURLConnection獲取到組件上的setPage()。

java.lang.ClassCastException: sun.net.www.protocol.http.HttpURLConnection cannot be cast to javax.net.ssl.HttpsURLConnection

這是我得到的錯誤。

有任何解決辦法嗎?

URL url = new URL("https://www.lalala.tk/website.html");
HttpsURLConnection httpsConn = (HttpsURLConnection) url.openConnection();

您輸入了錯誤的類。 我打賭您的代碼中的某個地方

import javax.net.ssl.HttpsURLConnection;

但相反,它應該是

import sun.net.www.protocol.http.HttpURLConnection;

嘗試更換進口,我相信它將解決。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM