0
回答
Android下HTTPS协议如何提交POST请求 或者在Xutils框架下
终于搞明白,存储TCO原来是这样算的>>>   

HTTPS下有CER和truststore的文件;

如何通过Xutils插件 来实现post请求

JAVA spring包下的源码

System.setProperty("javax.net.ssl.trustStore", "E:\\server-keystore\\tomcat.truststore");
		ClientHttpRequest request;
		 String url="https://www.xzcs.com:8443";
		request = new SimpleClientHttpRequestFactory().createRequest(new URI(url), HttpMethod.POST);
		// 设置请求�?
		request.getHeaders().setContentType(MediaType.APPLICATION_JSON);
		//这里是构造一个json字符串,用来实现登陆操作,格式可以参见接口文�?
		String requestStr = "{'head':{'appVerNo':'1.0.0','functionNo':'4'},'param':{'userName':'13509329937','password':'333333','rememberMe':'yes'}}";
		request.getBody().write(requestStr.getBytes("utf-8"));
		request.getBody().flush();

		// 发�?�请求,response变量接收返回的响应信�?
		ClientHttpResponse response = request.execute();
		//下面的代码是从response中取出返回的信息,并显示在控制台
		InputStream inputStream = response.getBody();
		byte[] bs = new byte[inputStream.available()];
		inputStream.read(bs);
		String str = new String(bs);
		System.out.println("response:" + str);



举报
打算a
发帖于8个月前 0回/867阅
顶部