HttpURLConnection GET request getting 400 Bad Request
问题 I am trying to do a GET request with some parameters in Java using HttpURLConnection. Everytime I do this however, I get a 400: Bad Request each time. What do I need to change to make it work? String url = "http://www.awebsite.com/apath?p1=v1&p2=v2&p3=v3"; HttpURLConnection conn = (HttpURLConnection)new URL(url).openConnection(); conn.setDoInput(true); conn.setDoOutput(false); conn.setUseCaches(false); conn.setRequestMethod("GET"); conn.setRequestProperty("Host", "www.awebsite.com"); conn