接收
private String getBodyStr(javax.servlet.http.HttpServletRequest request) throws IOException {
BufferedReader reader = request.getReader();
String readLine = "";
StringBuffer strBuf = new StringBuffer();
while ((readLine = reader.readLine()) != null){
strBuf.append(readLine);
logger.info(readLine);
}
readLine = strBuf.toString();
return readLine;
}
发送
private void writeOut(javax.servlet.http.HttpServletResponse response, String data) throws IOException {
response.setContentType("application/json;charset=UTF-8");
ServletOutputStream outputStream = response.getOutputStream();
outputStream.write(data.getBytes("UTF-8"));
outputStream.flush();
}