在现在rest接口越来越流行的情况下,前后端交互也变得更加便捷,
难免在自测试中会用到较多的http请求
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.URL;
import java.net.URLConnection;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
/**
* Created by tr on 2016/9/30.
*/
public class HttpRequestDiy {
/*
get
*/
public static String sendGet(String url,String parm){
String result = "";
String sendurl = url+"?"+parm;
BufferedReader in=null;
try{
//生成url
URL realurl = new URL(sendurl);
//建立链接对象
URLConnection connection = realurl.openConnection();
//设置请求头
connection.setRequestProperty("accept", &