Json Chinese garbled solution when HttpClient uses post and get

Json Chinese garbled solution when HttpClient uses post and get

http://blog.csdn.net/caoyicheng1/article/details/43754197

 

                // post response
		req.setCharacterEncoding("UTF-8"); // 转码
		System.out.println(req.getMethod());
		System.out.println(req.getContentType().toString());
		String requestJson = "";
		// Get the input stream reader for the post request
		// Receive the incoming data in the form of a stream and specify the encoding method =================================== =========
		BufferedReader br = new BufferedReader(new InputStreamReader(
				(ServletInputStream) req.getInputStream(), "UTF-8"));
		// ===========================================================================
		// Convert input stream to string
		StringBuffer sb = new StringBuffer();
		String temp;
		while ((temp = br.readLine()) != null) {
			sb.append(temp);
		}
		br.close(); // close the reader
		requestJson = sb.toString();

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326982786&siteId=291194637