java调用http接口并解析返回的json对象
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLEncoder;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import net.sf.json.JSONObject;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
public class Test {
//调用http接口
@RequestMapping(value="testInterfaces.htm", method={RequestMethod.GET, RequestMethod.POST})
public void testInterfaces(HttpServletRequest request) throws Exception{
//传入中文参数并设置编码格式
String param = "{\"url\":\"中文\"}"