Struts2中有多种结果类型? [英] Multiple result types in Struts2?

查看:103
本文介绍了Struts2中有多种结果类型?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用Tiles的Struts2应用程序。如何在动作映射中获得多个结果类型?因为我需要将de输出设置为JSON数据,并将Tiles同时设置。我试过了:

I have a Struts2 application where I using Tiles. How can I get multiple result types in action-mappings? because I need to set de output as JSON data, and Tiles simultaneous. I have tried:

<action
    name="home"
    class="com.deveto.struts.actions.HomeAction" >
    <result name="success" type="tiles,json">tiles.home</result>
</action>

但这不起作用

推荐答案

据我所知,没有办法同时归还多件事。一旦完成所有磁贴工作,浏览器只会期待一件事,无论是JSON还是HTML。

To my knowledge there is no way to return multiple things simultaneously. The browser will only be expecting one thing, either the JSON or the HTML once all the tiles stuff is done.

我可以想到两种方法:双重请求(每个结果类型一个)或使用一个生成另一个(获取JSON并使用JavaScript在客户端上构建HTML)。

I can think of two ways to do this: double request (one for each result type) or use one to generate the other (get the JSON and use JavaScript to construct the HTML on the client).

你想要什么?完成你需要两个结果?

What are you trying to accomplish that you need both results?

这篇关于Struts2中有多种结果类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆