第1个回答 推荐于2016-11-02
/**
* 响应xml
* @param response
* @param content
*/
public static void responseContent(HttpServletResponse response,String content){
try {
//把xml字符串写入响应
byte[] xmlData = content.getBytes();
response.setContentLength(xmlData.length);
ServletOutputStream os = response.getOutputStream();
os.write(xmlData);
os.flush();
os.close();
} catch (IOException e) {
e.printStackTrace();
}
}