纯servlet返回xml数据

...

void doget.....

response.setContentType("application/xml");//设置格式
  PrintWriter out = response.getWriter();
  String agentId = request.getParameter("AgentID");
  
  MonitorService monitorService = ServiceFactory.getService(MonitorService.class);
  out.println(monitorService.getRestCountByAgentId(agentId));//返回
  out.flush();
  out.close();

原文地址:https://www.cnblogs.com/wflxz/p/5133763.html