Struts Action返回xml

struts中的action如何返回xml,google之,so easy!

在struts.xml中配置

1 <action name="chart" class="chartAction">
2     <result name="xmlMessage" type="plainText"></result>
3 </action>

哦,原来result中name和type是这样的,那么action怎么写呢??

1 public void test() throws IOException{
2     HttpServletResponse response = ServletActionContext.getResponse();
3     PrintWriter out = response.getWriter();
4     response.setContentType("text/xml;charset=UTF-8");
5     //返回xml
6     out.write(xml);
7 }

OK,测试一下吧...

原文地址:https://www.cnblogs.com/yiban/p/struts_action_xml.html