httpClient Post例子,Http 四种请求访问代码 HttpGet HttpPost HttpPut HttpDelete
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;
} }
- import java.io.IOException;
- import java.util.List;
- import javax.servlet.ServletInputStream;
- import javax.servlet.http.HttpServletRequest;
- import javax.servlet.http.HttpServletResponse;
- import org.apache.commons.httpclient.DefaultHttpMethodRetryHandler;
- import org.apache.commons.httpclient.HttpClient;
- import org.apache.commons.httpclient.HttpStatus;
- import org.apache.commons.httpclient.NameValuePair;
- import org.apache.commons.httpclient.methods.PostMethod;
- import org.apache.commons.httpclient.params.HttpMethodParams;
- import org.apache.commons.io.IOUtils;
- import org.dom4j.Document;
- import org.dom4j.DocumentException;
- import org.dom4j.DocumentHelper;
- import org.dom4j.Element;
- import org.slf4j.Logger;
- import org.slf4j.LoggerFactory;
- import org.springframework.stereotype.Controller;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.bind.annotation.RequestMethod;
- import com.eecn.warehouse.api.model.Address;
- import com.eecn.warehouse.api.model.User;
- import com.eecn.warehouse.utils.FoodBase;
- import com.frogsing.common.api.open.storage.hy.TCustomer;
- import com.frogsing.common.open.tools.xmlUtils;
- import com.google.common.collect.Lists;
- import com.thoughtworks.xstream.XStream;
- @Controller
- @RequestMapping(value = {"/api"})
- public class ApiAction {
- private static Logger logger = LoggerFactory.getLogger(ApiAction.class);
- public static final String SERVER_URL = "http://192.168.1.100/api/StorageApi";
- @RequestMapping(value = {"/StorageApi"}, method = RequestMethod.POST)
- public String storageApi(TCustomer model, HttpServletRequest request, HttpServletResponse response) throws DocumentException {
- String xml = request.getParameter("xml");
- String signature = request.getParameter("signature");
- //************************http client*******************//
- PostMethod postMethod = null;
- try {
- // 构造HttpClient的实例
- HttpClient httpClient = new HttpClient();
- // 设置连接超时
- httpClient.getHttpConnectionManager().getParams().setConnectionTimeout(10000);
- // 设置字符集
- httpClient.getParams().setParameter(HttpMethodParams.HTTP_CONTENT_CHARSET, "UTF-8");
- // 创建POST方法的实例
- postMethod = new PostMethod(SERVER_URL);
- // 使用系统提供的默认的恢复策略 该策略在碰到IO异常的时候将自动重试3次。
- postMethod.getParams().setParameter(HttpMethodParams.SO_TIMEOUT, 20000);
- // 异常时,重试处理器
- postMethod.getParams().setParameter(HttpMethodParams.RETRY_HANDLER, new DefaultHttpMethodRetryHandler());
- //参数
- NameValuePair[] nameValuePairs = new NameValuePair[2];
- nameValuePairs[0] = new NameValuePair("xml", xml);
- nameValuePairs[1] = new NameValuePair("signature", signature);
- // 将参数加入到请求方法中
- postMethod.setRequestBody(nameValuePairs);
- // 发送连接
- int statusCode = httpClient.executeMethod(postMethod);
- if (statusCode == HttpStatus.SC_OK) {
- String result = postMethod.getResponseBodyAsString();
- logger.info("返回数据1:" + result);
- logger.info("字符集:" + postMethod.getResponseCharSet());
- String rspXml = new String(postMethod.getResponseBody(), "UTF-8");
- logger.info("返回数据2:" + rspXml);
- Document document = DocumentHelper.parseText(rspXml);
- Element signatureNode = (Element)document.selectSingleNode("//signature");
- Element dataNode = (Element)document.selectSingleNode("//data");
- String signXml = signatureNode.getText();
- String dataXml = dataNode.getText();
- String pureXml = FoodBase.decodeXml(dataXml);
- request.setAttribute("pureXml", pureXml);
- request.setAttribute("signXml", signXml);
- }
- } catch (Exception e) {
- logger.error("http client invoke error.", e);
- } finally {
- if (postMethod != null) {
- postMethod.releaseConnection();
- }
- }
- //******************************************************//
- ServletInputStream inputStream = null;
- String rspXml = null;
- try {
- inputStream = request.getInputStream();
- rspXml = IOUtils.toString(inputStream, "UTF-8");
- } catch (IOException e) {
- logger.error("读取交易仓单返回数据错误.", e);
- }
- return "api/storage";
- }
- @RequestMapping(value = {"/MarketApi"}, method = RequestMethod.POST)
- public String marketApi(HttpServletRequest request, HttpServletResponse response) {
- return "api/market";
- }
- public static void main(String[] args) {
- XStream xstream = new XStream();
- xstream.alias("User", User.class);
- xstream.alias("Address", Address.class);
- //xStream.aliasAttribute(User.class, "name", "name");
- xstream.useAttributeFor(User.class, "name");
- List<Address> addressList = Lists.newArrayList();
- for (int i = 0; i < 3; i++) {
- Address address = new Address();
- address.setProvince("浙江");
- addressList.add(address);
- }
- User user = new User();
- user.setAddressList(addressList);
- user.setAccount("asddaa");
- user.setAge(23);
- user.setGender(0);
- user.setName("zhang");
- System.out.println(xstream.toXML(user));
- System.out.println(xmlUtils.toEntityXml(user));
- }
- }
get方法类似。
1、httpclient4.3.4 读取网页内容
特别说明:StreamUtils 只是做了简单的关闭流操作,这个类可有自己写,或者直接调用流关闭操作 谢谢
- package com.haokuaisheng.https;
- import java.io.ByteArrayOutputStream;
- import java.io.InputStream;
- import java.util.Arrays;
- import java.util.List;
- import org.apache.http.Consts;
- import org.apache.http.Header;
- import org.apache.http.HttpEntity;
- import org.apache.http.NameValuePair;
- import org.apache.http.client.entity.UrlEncodedFormEntity;
- import org.apache.http.client.methods.CloseableHttpResponse;
- import org.apache.http.client.methods.HttpGet;
- import org.apache.http.client.methods.HttpPost;
- import org.apache.http.impl.client.CloseableHttpClient;
- import org.apache.http.impl.client.HttpClients;
- import org.apache.http.message.BasicHeader;
- import com.haokuaisheng.log.LogManager;
- import com.haokuaisheng.utils.StreamUtils;
- public class HttpUtils {
- 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");
- final static Header HEADER_CONNECTION = new BasicHeader( "connection" , "keep-alive");
- final static Header HEADER_CACHE_CONTROL = new BasicHeader( "cache-control" , "max-age=0");
- final static Header HEADER_ACCEPT = new BasicHeader( "accept" , "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8");
- final static Header HEADER_ACCEPT_ENCODING = new BasicHeader( "accept-encoding" , "gzip, deflate, sdch");
- final static Header HEADER_ACCEPT_LANGUAGE = new BasicHeader( "accept-language" , "zh-CN,zh;q=0.8,en;q=0.6");
- /**
- * 发送get请求
- * @param url 请求的url链接
- * @param charSet该链接字符编码
- * */
- public static String requestGet(String url , String charSet , NameValuePair...nameValuePairs){
- CloseableHttpClient httpclient = HttpClients.createDefault();
- CloseableHttpResponse response = null ;
- try {
- HttpGet httpget = new HttpGet( url );
- httpget.setHeader( HEADER_USER_AGENT ) ;
- httpget.setHeader( HEADER_CONNECTION ) ;
- httpget.setHeader( HEADER_CACHE_CONTROL ) ;
- httpget.setHeader( HEADER_ACCEPT ) ;
- httpget.setHeader( HEADER_ACCEPT_ENCODING);
- httpget.setHeader( HEADER_ACCEPT_LANGUAGE);
- response = httpclient.execute( httpget ) ;
- if(response.getStatusLine().getStatusCode() == 200){
- HttpEntity entity = response.getEntity() ;
- return inputStreamToString( entity , charSet );
- }
- } catch (Exception e) {
- LogManager.err("requestGet:" + url , e) ;
- }finally{
- try {
- response.close();
- httpclient.close();
- } catch (Exception e) {
- }
- }
- return "" ;
- }
- /**
- * 发送post请求
- * @param url 请求的url链接
- * @param charSet该链接字符编码
- * */
- public static String requestPost(String url , String charSet , NameValuePair...nameValuePairs){
- CloseableHttpClient httpclient = HttpClients.createDefault();
- CloseableHttpResponse response = null ;
- try {
- HttpPost httpPost = new HttpPost( url );
- httpPost.setHeader( HEADER_USER_AGENT ) ;
- httpPost.setHeader( HEADER_CONNECTION ) ;
- httpPost.setHeader( HEADER_CACHE_CONTROL ) ;
- httpPost.setHeader( HEADER_ACCEPT ) ;
- httpPost.setHeader( HEADER_ACCEPT_ENCODING);
- httpPost.setHeader( HEADER_ACCEPT_LANGUAGE);
- List<namevaluepair> formparams = Arrays.asList( nameValuePairs );
- UrlEncodedFormEntity formEntity = new UrlEncodedFormEntity(formparams, Consts.UTF_8);
- httpPost.setEntity( formEntity ) ;
- response = httpclient.execute( httpPost ) ;
- if(response.getStatusLine().getStatusCode() == 200){
- HttpEntity entity = response.getEntity() ;
- return inputStreamToString( entity , charSet );
- }
- } catch (Exception e) {
- LogManager.err("requestPost:" + url , e) ;
- }finally{
- try {
- response.close();
- httpclient.close();
- } catch (Exception e) {
- }
- }
- return "" ;
- }
- private static String inputStreamToString(HttpEntity entity , String charSet)
- throws Exception{
- InputStream is = null ;
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- try {
- is = entity.getContent() ;
- byte[]bytes = new byte[52428800] ;
- int buffer = -1;
- while( (buffer = is.read(bytes)) != -1){
- baos.write(bytes, 0, buffer) ;
- }
- return new String(baos.toByteArray() , charSet ) ;
- }finally{
- StreamUtils.closeInput( is );
- StreamUtils.closeOutput( baos );
- }
- }
- public static void main(String[] args) {
- //String result = requestGet("http://127.0.0.1:8080/a/?age=19" , "UTF-8" );
- //LogManager.info("\n" + result.replace("
- ", "\n"));
- String result = requestGet("http://neihanshequ.com/" , "UTF-8" );
- LogManager.info("\n" + result.replace("
- ", "\n"));
- /*
- String result = requestPost("http://127.0.0.1:8080/a/" , "UTF-8" , new BasicNameValuePair("name" , "中文中文中文")
- , new BasicNameValuePair("age" , "19") );
- LogManager.info(result.replace("
- ", "\n"));*/
- }
- }
- </namevaluepair>
采用jsoup-1.7.2. 和webmagic-core-0.5.2 jin
- package com.haokuaisheng.https;
- import java.util.List;
- import com.haokuaisheng.log.LogManager;
- import us.codecraft.webmagic.selector.Html;
- public class XPathUtils {
- public static void main(String[] args) throws Exception {
- String htmlStr = HttpUtils.requestGet("http://neihanshequ.com/", "UTF-8");
- Html html = new Html( htmlStr ) ;
- //List<String> titles = html.xpath( "//div[@class='post_item_body']/h3/a/text()" ).all() ;
- List<String> titles = html.xpath( "//span[@class='name']/text()" ).all() ;
- //List<String> bodys = html.xpath( "//div[@class='post_item_body']/p[@class='post_item_summary']/text()" ).all() ;
- List<String> bodys = html.xpath( "//h1[@class='title']/p/html()" ).all() ;
- int size = titles.size();
- for(int x=0; x<size; x++ ){
- String title = titles.get( x ) ;
- String body = bodys.get( x );
- LogManager.info("\n" + title + "-->" + body) ;
- }
- }
其它更深入:
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
httpClient Post例子,Http 四种请求访问代码 HttpGet HttpPost HttpPut HttpDelete的更多相关文章
- Http 四种请求访问代码 HttpGet HttpPost HttpPut HttpDelete .
String url = "http://www.baidu.com"; //将要访问的url字符串放入HttpPost中 HttpPost httpPost= new HttpP ...
- ajax参数传递之[HttpGet]/[HttpPost]/[HttpPut]/[HttpDelete]请求
$.ajax({ type: "get", url: "http://localhost:27221/api/Charging/GetByModel", con ...
- 接口测试中模拟post四种请求数据
https://www.jianshu.com/p/3b6d7aa2043a 一.背景介绍 在日常的接口测试工作中,模拟接口请求通常有两种方法,fiddler模拟和HttpClient模拟. Fidd ...
- HttpwebClient的四种请求方式
最近悟出来一个道理,在这儿分享给大家:学历代表你的过去,能力代表你的现在,学习代表你的将来. 十年河东十年河西,莫欺少年穷. 本文旨在发布代码,供自己参考,也供大家参考,谢谢. 正题: Ht ...
- 【spring springmvc】这里有你想要的SpringMVC的REST风格的四种请求方式
概述 之前的文章springmvc使用注解声明控制器与请求映射有简单提到过控制器与请求映射,这一次就详细讲解一下SpringMVC的REST风格的四种请求方式及其使用方法. 你能get的知识点 1.什 ...
- Vue 封装axios(四种请求)及相关介绍(十三)
Vue 封装axios(四种请求)及相关介绍 首先axios是基于promise的http库 promise是什么? 1.主要用于异步计算 2.可以将异步操作队列化,按照期望的顺序执行,返回符合预期的 ...
- [技术博客]OKhttp3使用get,post,delete,patch四种请求
OKhttp3使用get,post,delete,patch四种请求 1.okhttp简介 okhttp封装了大量http操作,大大简化了安卓网络请求操作,是现在最火的安卓端轻量级网络框架.如今okh ...
- thinkphp四种url访问方式详解
本文实例分析了thinkphp的四种url访问方式.分享给大家供大家参考.具体分析如下: 一.什么是MVC thinkphp的MVC模式非常灵活,即使只有三个中和一个也可以运行. M -Model 编 ...
- thinkPHP四种URL访问方式(二)
原文:thinkPHP四种URL访问方式(二) 四.url的4种访问方式 1.PATHINFO 模式 -- (重点) http://域名/项目名/入口文件/模块名/方法名/键1/值1/键2/ ...
随机推荐
- 一眼看穿👀JS基本概念
前段时间忙,好久没更新了,继续梳理基础知识这期总结的是JS的基本概念 标识符 所谓的标识符是指变量,函数属性的名字,或者函数的参数 第一个字符必须是一个字母,下划线(_)或者一个美元符号($),其他字 ...
- GBRT(GBDT)(MART)(Tree Net)(Tree link)
源于博客 GBRT(梯度提升回归树)有好多名字,标题全是它的别名. 它是一种迭代的回归树算法,由多棵回归树组成,所有树的结论累加起来得到最终结果.在被提出之初与SVM一起被认为是泛化能力较强的算法. ...
- Linux常用命令2 权限管理命令
1.权限管理命令:chmod 上面图片中的ugoa与rwx并不是一个命令,而是不同选项 u 所有者 g 所属组 o 其他人 a 所有人 r 读取权限 w写入权限 x 执行权限 chmod u+x ...
- PSPP:顶替SPSS常用功能的优秀软件, Linux 下的经济学用软件
几个替代SPSS的软体Salstat http://salstat.sourceforge.net/PSPP http://www.gnu.org/software/pspp/pspp.htmlR h ...
- linux中的用户、群组和权限
linux中的用户.群组和权限 新建用户natasha,uid为1000,gid为555,备注信息为“master” groupadd -g 555 natasha useradd -u 1 ...
- Spring中使用DataSourceTransactionManager进行事务管理的xml配置
在一个业务的实现过程中,可能需要多条sql完成对数据库的操作,比如账户登录,需要匹配用户名和密码,然后要增加积分,还要记录登录的ip和时间,这可能需要三个sql语句,这三个语句应当是一个整体,任意一个 ...
- day39-Spring 15-Spring的JDBC模板:C3P0连接池配置
<!-- 配置C3P0连接池 --> <bean id="dataSource2" class="com.mchange.v2.c3p0.ComboPo ...
- 洛谷 P1027 Car的旅行路线 最短路+Dijkstra算法
目录 题面 题目链接 题目描述 输入输出格式 输入格式 输出格式 输入输出样例 输入样例 输出样例 说明 思路 AC代码 总结 题面 题目链接 P1027 Car的旅行路线 题目描述 又到暑假了,住在 ...
- python爬虫:一些爬虫常用的技巧
1.基本抓取网页 get方法 import urllib2 url = "http://www.baidu.com" response = urllib2.urlopen(url) ...
- 简单利用XSS获取Cookie信息实例演示
简单利用XSS获取Cookie信息实例演示 首先要找到一个有XXS的站,这里就不整什么大站了,谷歌一下inurl:'Product.asp?BigClassName',搜出来的命中率也比较高.随便 ...