String urlStr = "http://172.16.1.21/customServiceAction.domethod=searchCustomServciesForWebJydt";
httpConn = (HttpURLConnection) new URL(urlStr).openConnection();
int responseCode = httpConn.getResponseCode();
if(responseCode == HttpURLConnection.HTTP_OK){
BufferedReader br = new BufferedReader(new InputStreamReader(httpConn.getInputStream()));
String sCurrentLine = "";
String sTotalString = "";
while((sCurrentLine = br.readLine()) != null){
sTotalString += sCurrentLine;
}
System.out.println("返回的xml为:"+sTotalString);返回xml文件中 中文乱码 如 <realName>閭鐞?</realName>
接口返回xml中的设置是utf8的 我这边相当于前台调用 试过各种编码转换sTotalString = new String(sTotalString.getBytes("ISO8859-1"),"UTF-8"); 都没用 已经折磨了我一天了 希望高手能帮我下
httpConn = (HttpURLConnection) new URL(urlStr).openConnection();
int responseCode = httpConn.getResponseCode();
if(responseCode == HttpURLConnection.HTTP_OK){
BufferedReader br = new BufferedReader(new InputStreamReader(httpConn.getInputStream()));
String sCurrentLine = "";
String sTotalString = "";
while((sCurrentLine = br.readLine()) != null){
sTotalString += sCurrentLine;
}
System.out.println("返回的xml为:"+sTotalString);返回xml文件中 中文乱码 如 <realName>閭鐞?</realName>
接口返回xml中的设置是utf8的 我这边相当于前台调用 试过各种编码转换sTotalString = new String(sTotalString.getBytes("ISO8859-1"),"UTF-8"); 都没用 已经折磨了我一天了 希望高手能帮我下
你把工作空间的编码集设置成utf-8(Window->Preferences->General->Workspace->Text file encoding)然后也不用转码了!然后结贴!
new InputStreamReader(httpConn.getInputStream(),"utf-8")
);
一个英文的,一个翻译的:
http://apicode.gicp.net/class.do?api=selectByfatherIndex&father=255
http://apicodecn.gicp.net/class.do?api=selectByfatherIndex&father=255