HttpURLConnection cannot be cast to java.net.ssl.HttpsURLConnection

 

源码如下:

.................

URL url = new URL(urlParams);
HttpsURLConnection con = (HttpsURLConnection) url.openConnection();



....................

 

 如果传入的urlParams为http格式,会导致类型转换失败,因为HttpsURLConnection 只接收https格式的url

image

 

posted @ 2025-10-13 11:36  123456~~~  阅读(3)  评论(0)    收藏  举报
© 2026 你的名字 | 博客园