http国际化模拟请求

  现在好多系统都有国际化的需求。不同国家的人读到不同的语言数据。那么怎么模拟请求的时候区分是哪个国家的语言信息,代码说明。

HttpPost methed = new HttpPost("模拟请求的url");

methed.addHeader("Content-type","application/json;charset=utf-8");
methed.addHeader("Accept","application/json");
//methed.addHeader("Accept-Language","zh-CN");//模拟中文请求
methed.addHeader("Accept-Language","en-GB");//模拟英文请求

StringEntity strentity = new StringEntity("参数",Charset.forName("UTF-8"));

methed.setEntity(strentity);

HttpResponse response = new DefaultHttpClient().execute(methed);
HttpEntity httpEntity = response.getEntity();
result = EntityUtils.toString(httpEntity);
原文地址:https://www.cnblogs.com/xu-lei/p/6183214.html