接受xml字符串+以流的形式返回信息

前端之家收集整理的这篇文章主要介绍了接受xml字符串+以流的形式返回信息前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
public void test1(){
try {
ActionContext ctx = ActionContext.getContext();
HttpServletRequest request = (HttpServletRequest)ctx.get(ServletActionContext.HTTP_REQUEST);
HttpServletResponse response = (HttpServletResponse)ctx.get(ServletActionContext.HTTP_RESPONSE);

InputStream inputStream;

inputStream = request.getInputStream();

String strMessage = "";
String strResponse = "";
BufferedReader reader;
reader = new BufferedReader(new InputStreamReader(inputStream,"utf-8"));
while ((strMessage = reader.readLine()) != null) {
strResponse += strMessage;
}
reader.close();
System.out.println(strResponse);

inputStream.close();

//返回信息的部分

PrintWriter printWriter = response.getWriter(); printWriter.write("SUCCESS"); printWriter.flush(); printWriter.close();

} catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } 原文链接:https://www.f2er.com/xml/295652.html

猜你在找的XML相关文章