用HttpURLConnection请求百度首页成功,(GET请求)
请求这个地址也成功:http://10.207.112.191:8080,说明后台服务器可用
但请求这个地址不成功:http://10.207.112.191:8080/user
/user后台测试代码:
用的是SpringMVC
@RequestMapping(value = "/user", method = RequestMethod.GET)
public void Reply(HttpServletResponse response) throws IOException {
PrintWriter out = response.getWriter();
System.out.println("来自安卓");
out.print("OK");
out.flush();
out.close();
}
logcat:
D/NetworkSecurityConfig: No Network Security Config specified, using platform default
D/Tag: 未进入http
W/System.err: java.io.FileNotFoundException: http://10.207.112.191:8080/user
W/System.err: at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:250)
W/System.err: at hope.HttpUtil.HttpUtil$1.run(HttpUtil.java:43)
W/System.err: at java.lang.Thread.run(Thread.java:761)
相关分类