怎么获取服务端响应内容?
代码如下,我上传图片到一个云服务器(),它会给我响应一些内容,
请问如何获取这个响应的内容?
html代码如下
<form method="post" action="http://up.qiniu.com/" enctype="multipart/form-data">
<input name="key" type="hidden" value="{FileID}">
<input name="x:custom_field_name" type="hidden" value="{SomeVal}">
<input name="token" type="hidden" value="{UploadToken}">
<input name="file" type="file" />
</form>
------解决方案--------------------各们高手帮一下
------解决方案--------------------用httpresponse就可以取到,返回的信息。
logger.debug("-------------------loginAysnSuggest start-------------------");
HttpClient httpclient = getHttpClient();
HttpPost post = getHttpPost("http://dynamic.12306.cn/otsweb/loginAction.do?method=loginAysnSuggest");
setReferer(post, "http://dynamic.12306.cn/otsweb/loginAction.do?method=init");
setBrowser(post);
// 创建客户端
// HttpClient httpclient = getHttpClient();
// HttpClient httpclient = new DefaultHttpClient();
// HttpPost post = getHttpPost(Constants.POST_UTL_LOGINACTION_LOGINAYSNSUGGEST);
ResponseHandler<String> responseHandler = new BasicResponseHandler();
String responseBody = null;
try {
responseBody = httpclient.execute(post, responseHandler);
logger.debug(responseBody);
} catch (Exception e) {
logger.warn(e.getMessage());
e.printStackTrace();
} finally {
httpclient.getConnectionManager().shutdown();
}
------解决方案--------------------用ajax就可以了
<html>
<head>
<script type="text/javascript" src="./js/post.js"></script>
<script type="text/javascript" src="./js/test/jquery-2.02.js"></script>
<script type="text/javascript" src="./js/test/form.js"></script>
<script type="text/javascript">
// wait for the DOM to be loaded