惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

D
DataBreaches.Net
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
云风的 BLOG
云风的 BLOG
B
Blog
博客园 - Franky
I
InfoQ
A
About on SuperTechFans
博客园_首页
L
LangChain Blog
量子位
腾讯CDC
Microsoft Security Blog
Microsoft Security Blog
博客园 - 【当耐特】
美团技术团队
V
V2EX
Apple Machine Learning Research
Apple Machine Learning Research
雷峰网
雷峰网
MongoDB | Blog
MongoDB | Blog
Microsoft Azure Blog
Microsoft Azure Blog
月光博客
月光博客
T
The Blog of Author Tim Ferriss
P
Proofpoint News Feed
G
Google Developers Blog
Last Week in AI
Last Week in AI

博客园 - cyberghost

Padavan 路由器配置 Cloudflare DDNS Linux关闭占用特定端口的进程 Jackson反序列化泛型List Oracle SQL Developer更改DATE日期的显示格式 解决Navicat导入psc备份文件数据为空 Maven配置环境变量 org.hibernate.LazyInitializationException: could not initialize proxy - no Session Maven项目导出jar包 Eclipse配置Go语言开发环境(GoEclipse) Maven项目设置JDK版本 PowerDesigner16下载和破解 Ubuntu安装JDK配置环境变量 Ubuntu添加eclipse快捷方式 JDK配置环境变量 springMVC获得HttpServletRequest对象 FusionCharts Free解决setDataURL中文乱码 使用FusionCharts Free显示图表(JSP) Ajax实现表单验证 Java判断指定日期是星期几
Struts Action返回xml
cyberghost · 2013-09-06 · via 博客园 - cyberghost

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,测试一下吧...

posted @ 2013-09-06 10:16  cyberghost  阅读(386)  评论(0)    收藏  举报