httpclient post方法

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
//----1、
HttpPost request = new HttpPost(url);
// 先封装一个 JSON 对象
JSONObject param = new JSONObject();
param.put("name""rarnu");
param.put("password""123456");
// 绑定到请求 Entry
StringEntity se = new StringEntity(param.toString());
request.setEntity(se);
// 发送请求
HttpResponse httpResponse = new DefaultHttpClient().execute(request);
// 得到应答的字符串,这也是一个 JSON 格式保存的数据
String retSrc = EntityUtils.toString(httpResponse.getEntity());
// 生成 JSON 对象
JSONObject result = new JSONObject( retSrc);
String token = result.get("token");
Http 四种请求访问代码 HttpGet HttpPost HttpPut HttpDelete
逻辑: String url = "http://www.baidu.com"; //将要访问的url字符串放入HttpPost中 HttpPost httpPost = new HttpPost(url); //请求头 放置一些修改http请求头和cookie httpPost.setHeader("Accept", "application/json"); ...... //如果是HttpPost或者HttpPut请求需要在请求里加参数,而HttpGet或者HttpDelete请求则可以直接拼接到url字符串后面 //向HttpPost中加入参数 List<NameValuePair> values = new ArrayList<NameValuePair>(); values.add(new NameValuePair("id", "1")); values.add(new NameValuePair("name", "xiaohong")); httpPost.setEntity(new UrlEncodeFormEntity(values, HTTP.UTF_8)); //进行转码 //实例HttpClient 并执行带有HttpPost的方法,返回HttpResponse 响应,再进行操作 HttpClient httpClient = new DefaultHttpClient(); HttpResponse httpResponse = httpClient.execute(httpPost); int statusCode = httpResponse.getStatusLine().getStatusCode(); //返回状态码 ,用来进行识别或者判断访问结果 if(statusCode == 200){   Instream in = httpResponse.getEntity().getContent(); //要处理该数据流是否为GZIP流 } 示例代码如下: package cn.dratek.haoyingsheng.manager.client; import cn.dratek.haoyingsheng.manager.util.ResourceUtil;
import net.dratek.browser.http.Cookie;
import net.dratek.browser.http.CookieManager;
import net.dratek.browser.http.URL;
import org.apache.http.*;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpDelete;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.methods.HttpPut;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.protocol.HTTP; import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.util.List; public class HttpNetClient {
/**
* 所有get 请求底层调用方法
*
* @param url 请求url
* @return byte[] response data
*/
public static byte[] doGet(String url) {
InputStream in;
byte[] bre = null;
HttpResponse response;
CookieManager manager = CookieManager.getInstance();
if (url != null && url.length() != 0) {
URL myURL = URL.parseString(url);
Cookie[] cookies = manager.getCookies(myURL);
HttpGet httpGet = new HttpGet(url);
if (cookies != null && cookies.length > 0) {
StringBuilder sb = new StringBuilder();
for (Cookie ck : cookies) {
sb.append(ck.name).append('=').append(ck.value).append(";");
}
String sck = sb.toString();
if (sck.length() > 0) {
httpGet.setHeader("Cookie", sck);
} }
httpGet.setHeader("Accept-Encoding", "gzip, deflate");
httpGet.setHeader("Accept-Language", "zh-CN");
httpGet.setHeader("Accept", "application/json, application/xml, text/html, text/*, image/*, */*");
try {
response = new DefaultHttpClient().execute(httpGet);
if (response != null) {
int statusCode = response.getStatusLine().getStatusCode();
if (statusCode == 200 || statusCode == 403) {
Header[] headers = response.getHeaders("Set-Cookie");
if (headers != null && headers.length > 0) {
for (Header header : headers) {
manager.setCookie(myURL, header.getValue());
}
}
in = response.getEntity().getContent();
if (in != null) {
bre = ResourceUtil.readStream(in);
} }
} } catch (IOException e) {
e.printStackTrace();
}
} return bre; } /**
* 所有Post 请求底层调用方法
*
* @param url 请求url
* @param values 传递的参数
* @return byte[] 返回数据 or null
*/
public static byte[] doPost(String url, List<NameValuePair> values) {
System.out.println("url = " + url);
byte[] bytes = null;
HttpResponse response;
InputStream inputStream = null;
CookieManager manager = CookieManager.getInstance();
if (url != null && url.length() != 0) {
URL myurl = URL.parseString(url);
Cookie[] cookies = manager.getCookies(myurl);
HttpPost post = new HttpPost(url);
if (cookies != null && cookies.length > 0) {
StringBuilder sb = new StringBuilder();
for (Cookie ck : cookies) {
sb.append(ck.name).append('=').append(ck.value).append(";");
}
String sck = sb.toString();
if (sck.length() > 0) {
post.setHeader("Cookie", sck);
} }
post.setHeader("Accept-Encoding", "gzip, deflate");
post.setHeader("Accept-Language", "zh-CN");
post.setHeader("Accept", "application/json, application/xml, text/html, text/*, image/*, */*");
DefaultHttpClient client = new DefaultHttpClient();
try {
if (values != null && values.size() > 0) {
post.setEntity(new UrlEncodedFormEntity(values, HTTP.UTF_8));
}
response = client.execute(post);
if (response != null) {
int statusCode = response.getStatusLine().getStatusCode();
if (statusCode == 200 || statusCode == 403) {
Header[] headers = response.getHeaders("Set-Cookie");
if (headers != null && headers.length > 0) {
for (Header header : headers) {
manager.setCookie(myurl, header.getValue());
}
}
inputStream = response.getEntity().getContent();
}
} } catch (UnsupportedEncodingException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
if (inputStream != null) {
bytes = ResourceUtil.readStream(inputStream);
}
}
return bytes;
} /**
* PUT基础请求
*
* @param url 请求地址
* @param values 提交参数
* @return byte[] 请求成功后的结果
*/
public static byte[] doPut(String url, List<NameValuePair> values) {
byte[] ret = null; CookieManager manager = CookieManager.getInstance();
if (url != null && url.length() > 0) {
URL myUrl = URL.parseString(url);
StringBuilder sb = new StringBuilder();
Cookie[] cookies = manager.getCookies(myUrl);
if (cookies != null && cookies.length > 0) {
for (Cookie cookie : cookies) {
sb.append(cookie.name).append("=").append(cookie.value).append(";");
} }
HttpPut request = new HttpPut(url);
String sck = sb.toString();
if (sck.length() > 0) {
request.setHeader("Cookie", sck);
}
request.setHeader("Accept-Encoding", "gzip, deflate");
request.setHeader("Accept-Language", "zh-CN");
request.setHeader("Accept", "application/json, application/xml, text/html, text/*, image/*, */*"); DefaultHttpClient client = new DefaultHttpClient();
if (values != null && values.size() > 0) {
try {
UrlEncodedFormEntity entity;
entity = new UrlEncodedFormEntity(values);
request.setEntity(entity);
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
}
try {
HttpResponse response = client.execute(request);
if (response != null) {
StatusLine statusLine = response.getStatusLine();
int statusCode = statusLine.getStatusCode();
if (statusCode == 200 || statusCode == 403) {
Header[] headers = response.getHeaders("Set-Cookie");
if (headers != null && headers.length > 0) {
for (Header header : headers) {
manager.setCookie(myUrl, header.getValue());
}
}
HttpEntity entity = response.getEntity();
InputStream inputStream = entity.getContent();
if (inputStream != null) {
ret = ResourceUtil.readStream(inputStream);
inputStream.close();
}
}
}
} catch (IOException e) {
e.printStackTrace();
}
}
return ret;
} /**
* Delete基础请求
*
* @param url 请求地址
* @return 请求成功后的结果
*/
public static byte[] doDelete(String url) { InputStream in;
byte[] bre = null;
HttpResponse response;
CookieManager manager = CookieManager.getInstance();
if (url != null && url.length() != 0) {
URL myurl = URL.parseString(url);
Cookie[] cookies = manager.getCookies(myurl);
HttpDelete delete = new HttpDelete(url);
if (cookies != null && cookies.length > 0) {
StringBuilder sb = new StringBuilder();
for (Cookie ck : cookies) {
sb.append(ck.name).append('=').append(ck.value).append(";");
}
String sck = sb.toString();
if (sck.length() > 0) {
delete.setHeader("Cookie", sck);
} }
delete.setHeader("Accept-Encoding", "gzip, deflate");
delete.setHeader("Accept-Language", "zh-CN");
delete.setHeader("Accept", "application/json, application/xml, text/html, text/*, image/*, */*");
try {
response = new DefaultHttpClient().execute(delete);
if (response != null) {
int statusCode = response.getStatusLine().getStatusCode();
if (statusCode == 200 || statusCode == 403) {
Header[] headers = response.getHeaders("Set-Cookie");
if (headers != null && headers.length > 0) {
for (Header header : headers) {
manager.setCookie(myurl, header.getValue());
}
}
in = response.getEntity().getContent();
if (in != null) {
bre = ResourceUtil.readStream(in);
} }
} } catch (IOException e) {
e.printStackTrace();
}
} return bre;
} }
  1. import java.io.IOException;
  2. import java.util.List;
  3. import javax.servlet.ServletInputStream;
  4. import javax.servlet.http.HttpServletRequest;
  5. import javax.servlet.http.HttpServletResponse;
  6. import org.apache.commons.httpclient.DefaultHttpMethodRetryHandler;
  7. import org.apache.commons.httpclient.HttpClient;
  8. import org.apache.commons.httpclient.HttpStatus;
  9. import org.apache.commons.httpclient.NameValuePair;
  10. import org.apache.commons.httpclient.methods.PostMethod;
  11. import org.apache.commons.httpclient.params.HttpMethodParams;
  12. import org.apache.commons.io.IOUtils;
  13. import org.dom4j.Document;
  14. import org.dom4j.DocumentException;
  15. import org.dom4j.DocumentHelper;
  16. import org.dom4j.Element;
  17. import org.slf4j.Logger;
  18. import org.slf4j.LoggerFactory;
  19. import org.springframework.stereotype.Controller;
  20. import org.springframework.web.bind.annotation.RequestMapping;
  21. import org.springframework.web.bind.annotation.RequestMethod;
  22. import com.eecn.warehouse.api.model.Address;
  23. import com.eecn.warehouse.api.model.User;
  24. import com.eecn.warehouse.utils.FoodBase;
  25. import com.frogsing.common.api.open.storage.hy.TCustomer;
  26. import com.frogsing.common.open.tools.xmlUtils;
  27. import com.google.common.collect.Lists;
  28. import com.thoughtworks.xstream.XStream;
  29. @Controller
  30. @RequestMapping(value = {"/api"})
  31. public class ApiAction {
  32. private static Logger logger = LoggerFactory.getLogger(ApiAction.class);
  33. public static final String SERVER_URL = "http://192.168.1.100/api/StorageApi";
  34. @RequestMapping(value = {"/StorageApi"}, method = RequestMethod.POST)
  35. public String storageApi(TCustomer model, HttpServletRequest request, HttpServletResponse response) throws DocumentException {
  36. String xml = request.getParameter("xml");
  37. String signature = request.getParameter("signature");
  38. //************************http client*******************//
  39. PostMethod postMethod = null;
  40. try {
  41. // 构造HttpClient的实例
  42. HttpClient httpClient = new HttpClient();
  43. // 设置连接超时
  44. httpClient.getHttpConnectionManager().getParams().setConnectionTimeout(10000);
  45. // 设置字符集
  46. httpClient.getParams().setParameter(HttpMethodParams.HTTP_CONTENT_CHARSET, "UTF-8");
  47. // 创建POST方法的实例
  48. postMethod = new PostMethod(SERVER_URL);
  49. // 使用系统提供的默认的恢复策略 该策略在碰到IO异常的时候将自动重试3次。
  50. postMethod.getParams().setParameter(HttpMethodParams.SO_TIMEOUT, 20000);
  51. // 异常时,重试处理器
  52. postMethod.getParams().setParameter(HttpMethodParams.RETRY_HANDLER, new DefaultHttpMethodRetryHandler());
  53. //参数
  54. NameValuePair[] nameValuePairs = new NameValuePair[2];
  55. nameValuePairs[0] = new NameValuePair("xml", xml);
  56. nameValuePairs[1] = new NameValuePair("signature", signature);
  57. // 将参数加入到请求方法中
  58. postMethod.setRequestBody(nameValuePairs);
  59. // 发送连接
  60. int statusCode = httpClient.executeMethod(postMethod);
  61. if (statusCode == HttpStatus.SC_OK) {
  62. String result = postMethod.getResponseBodyAsString();
  63. logger.info("返回数据1:" + result);
  64. logger.info("字符集:" + postMethod.getResponseCharSet());
  65. String rspXml = new String(postMethod.getResponseBody(), "UTF-8");
  66. logger.info("返回数据2:" + rspXml);
  67. Document document = DocumentHelper.parseText(rspXml);
  68. Element signatureNode = (Element)document.selectSingleNode("//signature");
  69. Element dataNode = (Element)document.selectSingleNode("//data");
  70. String signXml = signatureNode.getText();
  71. String dataXml = dataNode.getText();
  72. String pureXml = FoodBase.decodeXml(dataXml);
  73. request.setAttribute("pureXml", pureXml);
  74. request.setAttribute("signXml", signXml);
  75. }
  76. } catch (Exception e) {
  77. logger.error("http client invoke error.", e);
  78. } finally {
  79. if (postMethod != null) {
  80. postMethod.releaseConnection();
  81. }
  82. }
  83. //******************************************************//
  84. ServletInputStream inputStream = null;
  85. String rspXml = null;
  86. try {
  87. inputStream = request.getInputStream();
  88. rspXml = IOUtils.toString(inputStream, "UTF-8");
  89. } catch (IOException e) {
  90. logger.error("读取交易仓单返回数据错误.", e);
  91. }
  92. return "api/storage";
  93. }
  94. @RequestMapping(value = {"/MarketApi"}, method = RequestMethod.POST)
  95. public String marketApi(HttpServletRequest request, HttpServletResponse response) {
  96. return "api/market";
  97. }
  98. public static void main(String[] args) {
  99. XStream xstream = new XStream();
  100. xstream.alias("User", User.class);
  101. xstream.alias("Address", Address.class);
  102. //xStream.aliasAttribute(User.class, "name", "name");
  103. xstream.useAttributeFor(User.class, "name");
  104. List<Address> addressList = Lists.newArrayList();
  105. for (int i = 0; i < 3; i++) {
  106. Address address = new Address();
  107. address.setProvince("浙江");
  108. addressList.add(address);
  109. }
  110. User user = new User();
  111. user.setAddressList(addressList);
  112. user.setAccount("asddaa");
  113. user.setAge(23);
  114. user.setGender(0);
  115. user.setName("zhang");
  116. System.out.println(xstream.toXML(user));
  117. System.out.println(xmlUtils.toEntityXml(user));
  118. }
  119. }

get方法类似。

 
 
 
 
 
 
 
 
 
 
 
 

1、httpclient4.3.4 读取网页内容

特别说明:StreamUtils  只是做了简单的关闭流操作,这个类可有自己写,或者直接调用流关闭操作 谢谢

  1. package com.haokuaisheng.https;
  2. import java.io.ByteArrayOutputStream;
  3. import java.io.InputStream;
  4. import java.util.Arrays;
  5. import java.util.List;
  6. import org.apache.http.Consts;
  7. import org.apache.http.Header;
  8. import org.apache.http.HttpEntity;
  9. import org.apache.http.NameValuePair;
  10. import org.apache.http.client.entity.UrlEncodedFormEntity;
  11. import org.apache.http.client.methods.CloseableHttpResponse;
  12. import org.apache.http.client.methods.HttpGet;
  13. import org.apache.http.client.methods.HttpPost;
  14. import org.apache.http.impl.client.CloseableHttpClient;
  15. import org.apache.http.impl.client.HttpClients;
  16. import org.apache.http.message.BasicHeader;
  17. import com.haokuaisheng.log.LogManager;
  18. import com.haokuaisheng.utils.StreamUtils;
  19. public class HttpUtils {
  20. final static Header HEADER_USER_AGENT = new BasicHeader( "user-agent" , "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2700.0 Safari/537.36");
  21. final static Header HEADER_CONNECTION = new BasicHeader( "connection" , "keep-alive");
  22. final static Header HEADER_CACHE_CONTROL = new BasicHeader( "cache-control" , "max-age=0");
  23. final static Header HEADER_ACCEPT = new BasicHeader( "accept" , "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8");
  24. final static Header HEADER_ACCEPT_ENCODING = new BasicHeader( "accept-encoding" , "gzip, deflate, sdch");
  25. final static Header HEADER_ACCEPT_LANGUAGE = new BasicHeader( "accept-language" , "zh-CN,zh;q=0.8,en;q=0.6");
  26. /**
  27. * 发送get请求
  28. * @param url 请求的url链接
  29. * @param charSet该链接字符编码
  30. * */
  31. public static String requestGet(String url , String charSet , NameValuePair...nameValuePairs){
  32. CloseableHttpClient httpclient = HttpClients.createDefault();
  33. CloseableHttpResponse response = null ;
  34. try {
  35. HttpGet httpget = new HttpGet( url );
  36. httpget.setHeader( HEADER_USER_AGENT ) ;
  37. httpget.setHeader( HEADER_CONNECTION ) ;
  38. httpget.setHeader( HEADER_CACHE_CONTROL ) ;
  39. httpget.setHeader( HEADER_ACCEPT ) ;
  40. httpget.setHeader( HEADER_ACCEPT_ENCODING);
  41. httpget.setHeader( HEADER_ACCEPT_LANGUAGE);
  42. response = httpclient.execute( httpget ) ;
  43. if(response.getStatusLine().getStatusCode() == 200){
  44. HttpEntity entity = response.getEntity() ;
  45. return inputStreamToString( entity , charSet );
  46. }
  47. } catch (Exception e) {
  48. LogManager.err("requestGet:" + url , e) ;
  49. }finally{
  50. try {
  51. response.close();
  52. httpclient.close();
  53. } catch (Exception e) {
  54. }
  55. }
  56. return "" ;
  57. }
  58. /**
  59. * 发送post请求
  60. * @param url 请求的url链接
  61. * @param charSet该链接字符编码
  62. * */
  63. public static String requestPost(String url , String charSet , NameValuePair...nameValuePairs){
  64. CloseableHttpClient httpclient = HttpClients.createDefault();
  65. CloseableHttpResponse response = null ;
  66. try {
  67. HttpPost httpPost = new HttpPost( url );
  68. httpPost.setHeader( HEADER_USER_AGENT ) ;
  69. httpPost.setHeader( HEADER_CONNECTION ) ;
  70. httpPost.setHeader( HEADER_CACHE_CONTROL ) ;
  71. httpPost.setHeader( HEADER_ACCEPT ) ;
  72. httpPost.setHeader( HEADER_ACCEPT_ENCODING);
  73. httpPost.setHeader( HEADER_ACCEPT_LANGUAGE);
  74. List<namevaluepair> formparams = Arrays.asList( nameValuePairs );
  75. UrlEncodedFormEntity formEntity = new UrlEncodedFormEntity(formparams, Consts.UTF_8);
  76. httpPost.setEntity( formEntity ) ;
  77. response = httpclient.execute( httpPost ) ;
  78. if(response.getStatusLine().getStatusCode() == 200){
  79. HttpEntity entity = response.getEntity() ;
  80. return inputStreamToString( entity , charSet );
  81. }
  82. } catch (Exception e) {
  83. LogManager.err("requestPost:" + url , e) ;
  84. }finally{
  85. try {
  86. response.close();
  87. httpclient.close();
  88. } catch (Exception e) {
  89. }
  90. }
  91. return "" ;
  92. }
  93. private static String inputStreamToString(HttpEntity entity , String charSet)
  94. throws Exception{
  95. InputStream is = null ;
  96. ByteArrayOutputStream baos = new ByteArrayOutputStream();
  97. try {
  98. is = entity.getContent() ;
  99. byte[]bytes = new byte[52428800] ;
  100. int buffer = -1;
  101. while( (buffer = is.read(bytes)) != -1){
  102. baos.write(bytes, 0, buffer) ;
  103. }
  104. return new String(baos.toByteArray() , charSet ) ;
  105. }finally{
  106. StreamUtils.closeInput( is );
  107. StreamUtils.closeOutput( baos );
  108. }
  109. }
  110. public static void main(String[] args) {
  111. //String result = requestGet("http://127.0.0.1:8080/a/?age=19" ,  "UTF-8" );
  112. //LogManager.info("\n" + result.replace("
  113. ", "\n"));
  114. String result = requestGet("http://neihanshequ.com/" ,  "UTF-8" );
  115. LogManager.info("\n" + result.replace("
  116. ", "\n"));
  117. /*
  118. String result = requestPost("http://127.0.0.1:8080/a/" ,  "UTF-8" , new BasicNameValuePair("name" , "中文中文中文")
  119. ,  new BasicNameValuePair("age" , "19")  );
  120. LogManager.info(result.replace("
  121. ", "\n"));*/
  122. }
  123. }
  124. </namevaluepair>

采用jsoup-1.7.2. 和webmagic-core-0.5.2 jin

  1. package com.haokuaisheng.https;
  2. import java.util.List;
  3. import com.haokuaisheng.log.LogManager;
  4. import us.codecraft.webmagic.selector.Html;
  5. public class XPathUtils {
  6. public static void main(String[] args) throws Exception {
  7. String htmlStr = HttpUtils.requestGet("http://neihanshequ.com/", "UTF-8");
  8. Html html = new Html( htmlStr ) ;
  9. //List<String> titles = html.xpath( "//div[@class='post_item_body']/h3/a/text()" ).all() ;
  10. List<String> titles = html.xpath( "//span[@class='name']/text()" ).all() ;
  11. //List<String> bodys = html.xpath( "//div[@class='post_item_body']/p[@class='post_item_summary']/text()" ).all() ;
  12. List<String> bodys = html.xpath( "//h1[@class='title']/p/html()" ).all() ;
  13. int size = titles.size();
  14. for(int x=0; x<size; x++ ){
  15. String title = titles.get( x ) ;
  16. String body = bodys.get( x );
  17. LogManager.info("\n" +  title  + "-->" + body) ;
  18. }
  19. }

其它更深入:

http://www.th7.cn/Program/java/201605/859929.shtml

http://www.tuicool.com/articles/Unumeu

http://blog.csdn.net/binsweet/article/details/5861427

http://blog.csdn.net/csdnbsd/article/details/51850826

http://blog.csdn.net/kl28978113/article/details/51997201

http://blog.csdn.net/kl28978113/article/details/51997201

httpClient Post例子,Http 四种请求访问代码 HttpGet HttpPost HttpPut HttpDelete的更多相关文章

  1. Http 四种请求访问代码 HttpGet HttpPost HttpPut HttpDelete .

    String url = "http://www.baidu.com"; //将要访问的url字符串放入HttpPost中 HttpPost httpPost= new HttpP ...

  2. ajax参数传递之[HttpGet]/[HttpPost]/[HttpPut]/[HttpDelete]请求

    $.ajax({ type: "get", url: "http://localhost:27221/api/Charging/GetByModel", con ...

  3. 接口测试中模拟post四种请求数据

    https://www.jianshu.com/p/3b6d7aa2043a 一.背景介绍 在日常的接口测试工作中,模拟接口请求通常有两种方法,fiddler模拟和HttpClient模拟. Fidd ...

  4. HttpwebClient的四种请求方式

    最近悟出来一个道理,在这儿分享给大家:学历代表你的过去,能力代表你的现在,学习代表你的将来. 十年河东十年河西,莫欺少年穷.      本文旨在发布代码,供自己参考,也供大家参考,谢谢. 正题: Ht ...

  5. 【spring springmvc】这里有你想要的SpringMVC的REST风格的四种请求方式

    概述 之前的文章springmvc使用注解声明控制器与请求映射有简单提到过控制器与请求映射,这一次就详细讲解一下SpringMVC的REST风格的四种请求方式及其使用方法. 你能get的知识点 1.什 ...

  6. Vue 封装axios(四种请求)及相关介绍(十三)

    Vue 封装axios(四种请求)及相关介绍 首先axios是基于promise的http库 promise是什么? 1.主要用于异步计算 2.可以将异步操作队列化,按照期望的顺序执行,返回符合预期的 ...

  7. [技术博客]OKhttp3使用get,post,delete,patch四种请求

    OKhttp3使用get,post,delete,patch四种请求 1.okhttp简介 okhttp封装了大量http操作,大大简化了安卓网络请求操作,是现在最火的安卓端轻量级网络框架.如今okh ...

  8. thinkphp四种url访问方式详解

    本文实例分析了thinkphp的四种url访问方式.分享给大家供大家参考.具体分析如下: 一.什么是MVC thinkphp的MVC模式非常灵活,即使只有三个中和一个也可以运行. M -Model 编 ...

  9. thinkPHP四种URL访问方式(二)

    原文:thinkPHP四种URL访问方式(二) 四.url的4种访问方式      1.PATHINFO 模式 -- (重点) http://域名/项目名/入口文件/模块名/方法名/键1/值1/键2/ ...

随机推荐

  1. 一眼看穿👀JS基本概念

    前段时间忙,好久没更新了,继续梳理基础知识这期总结的是JS的基本概念 标识符 所谓的标识符是指变量,函数属性的名字,或者函数的参数 第一个字符必须是一个字母,下划线(_)或者一个美元符号($),其他字 ...

  2. GBRT(GBDT)(MART)(Tree Net)(Tree link)

    源于博客 GBRT(梯度提升回归树)有好多名字,标题全是它的别名. 它是一种迭代的回归树算法,由多棵回归树组成,所有树的结论累加起来得到最终结果.在被提出之初与SVM一起被认为是泛化能力较强的算法. ...

  3. Linux常用命令2 权限管理命令

    1.权限管理命令:chmod 上面图片中的ugoa与rwx并不是一个命令,而是不同选项 u 所有者  g 所属组 o 其他人 a 所有人 r 读取权限 w写入权限  x 执行权限 chmod u+x ...

  4. PSPP:顶替SPSS常用功能的优秀软件, Linux 下的经济学用软件

    几个替代SPSS的软体Salstat http://salstat.sourceforge.net/PSPP http://www.gnu.org/software/pspp/pspp.htmlR h ...

  5. linux中的用户、群组和权限

     linux中的用户.群组和权限   新建用户natasha,uid为1000,gid为555,备注信息为“master”   groupadd -g 555 natasha useradd -u 1 ...

  6. Spring中使用DataSourceTransactionManager进行事务管理的xml配置

    在一个业务的实现过程中,可能需要多条sql完成对数据库的操作,比如账户登录,需要匹配用户名和密码,然后要增加积分,还要记录登录的ip和时间,这可能需要三个sql语句,这三个语句应当是一个整体,任意一个 ...

  7. day39-Spring 15-Spring的JDBC模板:C3P0连接池配置

    <!-- 配置C3P0连接池 --> <bean id="dataSource2" class="com.mchange.v2.c3p0.ComboPo ...

  8. 洛谷 P1027 Car的旅行路线 最短路+Dijkstra算法

    目录 题面 题目链接 题目描述 输入输出格式 输入格式 输出格式 输入输出样例 输入样例 输出样例 说明 思路 AC代码 总结 题面 题目链接 P1027 Car的旅行路线 题目描述 又到暑假了,住在 ...

  9. python爬虫:一些爬虫常用的技巧

    1.基本抓取网页 get方法 import urllib2 url = "http://www.baidu.com" response = urllib2.urlopen(url) ...

  10. 简单利用XSS获取Cookie信息实例演示

    简单利用XSS获取Cookie信息实例演示   首先要找到一个有XXS的站,这里就不整什么大站了,谷歌一下inurl:'Product.asp?BigClassName',搜出来的命中率也比较高.随便 ...