接受xml字符串+以流的形式返回信息
发布时间:2020-12-16 08:46:05 所属栏目:百科 来源:网络整理
导读:public void test1(){ try { ActionContext ctx = ActionContext.getContext(); HttpServletRequest request = (HttpServletRequest)ctx.get(ServletActionContext.HTTP_REQUEST); HttpServletResponse response = (HttpServletResponse)ctx.get(ServletActio
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(); } }(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |