这样调用Struts2 的Aciton: tree.loadXML("/dhtmlxTree.action?userid=<%=id%>");
在Action中这样写:
public voidjdomDhtmlxTree() throws Exception {
HttpServletResponse response = ServletActionContext.getResponse();
......
Document xmlDocument = new Document(tree);
org.jdom.output.Format format = org.jdom.output.Format.getCompactFormat();
format.setEncoding("gb2312");
format.setIndent(" ");
XMLOutputter outputter = new XMLOutputter(format);
try {
response.setContentType("text/xml; charset=gb2312");
response.setHeader("Cache-Control", "no-cache");
outputter.output(xmlDocument, response.getWriter());
}
catch (IOException e) {
e.printStackTrace();
}
}
struts.xml中这样配置
<action name="dhtmlxTree" class="dhtmlxTree" method="jdomDhtmlxTree">
</action>
这样执行没有报错,不知道会不会有什么问题?请大家帮忙,分析一下,谢谢!
问题补充:
这是struts2的特征之一。
gaoran2008, 能不能说的清楚一点,能告诉我在Struts2的参考中哪有提到吗,我没找到,谢谢!
在Struts2这样结束Action的请求行吗?
- 写回答
- 好问题 0 提建议
- 追加酬金
- 关注问题
- 邀请回答
-
3条回答 默认 最新
- kyo100900 2008-09-01 09:43关注
这是很常见的用法,不想有返回值,自然会将调用方法写成void类型。
Struts2/webwork 设计的初衷就是要实现一个[color=red]简单而且灵活[/color]的框架,没有很严格的使用限制,文档对这些过于细化的问题也不会说太多。本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报
悬赏问题
- ¥15 请教一下各位,为什么我这个没有实现模拟点击
- ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
- ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
- ¥20 有关区间dp的问题求解
- ¥15 多电路系统共用电源的串扰问题
- ¥15 slam rangenet++配置
- ¥15 有没有研究水声通信方面的帮我改俩matlab代码
- ¥15 ubuntu子系统密码忘记
- ¥15 保护模式-系统加载-段寄存器
- ¥15 电脑桌面设定一个区域禁止鼠标操作