Java IllegalArgumentException: Illegal Character in Scheme Name - 解决方法
The error message "java.lang.IllegalArgumentException: Illegal character in scheme name at index 0" indicates that there is an issue with the scheme name in the URL. In this case, the scheme name is "https://", which is a valid scheme name.
However, it seems like you are trying to parse a URL with non-ASCII characters in it, specifically the Chinese characters "中文解析". URL strings should only contain ASCII characters, and non-ASCII characters need to be URL-encoded.
To fix the issue, you should encode the Chinese characters using the appropriate encoding scheme, such as UTF-8. In Java, you can use the URLEncoder class to URL-encode the non-ASCII characters before parsing the URL:
import java.net.URLEncoder;
String url = \"https://192.168.35.210:9443/api/auth \" + URLEncoder.encode(\"中文解析\", \"UTF-8\");
This will encode the Chinese characters into a URL-safe format, allowing you to parse the URL without encountering the IllegalArgumentException.
原文地址: https://www.cveoy.top/t/topic/pZUu 著作权归作者所有。请勿转载和采集!