How to get redirected URL and content using HttpURLConnection

后端 未结 2 2101
没有蜡笔的小新
没有蜡笔的小新 2020-12-03 17:41

Sometimes my URL will redirect to a new page, so I want to get the URL of the new page.

Here is my code:

URL url = new URL(\"http://stackoverflow.com         


        
2条回答
  •  难免孤独
    2020-12-03 18:18

    actually we can use HttpClient, which we can set HttpClient.followRedirect(true) HttpClinent will handle the redirect things.

提交回复
热议问题