There are many http frameworks. There is no need to write all http requests yourself. For example, there is okhttp, and there is also an annotation-based http framework: retrofit.
HttpURLConnection will not jump based on the return code You need to parse the HTTP status code from the result. If it is 302, then take out the referer attribute in the returned HTTP header. This is the address to which you will be redirected after logging in It will be OK to initiate the request again after redirecting the address
It is not recommended to use JDK’s HttpURLConection, which is not easy to use. It is recommended to use Apache httpClient or OKHTTP
There are many http frameworks. There is no need to write all http requests yourself. For example, there is okhttp, and there is also an annotation-based http framework: retrofit.
HttpURLConnection will not jump based on the return code
You need to parse the HTTP status code from the result. If it is 302, then take out the referer attribute in the returned HTTP header. This is the address to which you will be redirected after logging in
It will be OK to initiate the request again after redirecting the address
It is not recommended to use JDK’s HttpURLConection, which is not easy to use. It is recommended to use Apache httpClient or OKHTTP