我在一个应用程序中使用了tiles,但我也使用ajax请求来获得json类型的响应,并希望通过tiles来显示它。我可以在我的struts.xml中设置两种结果类型吗?
我试过但失败了..。
<action name="*CampData" method="{1}" class="com.contaque.monitor.CampAction">
<result name="get" type="tiles+json">getCampData</result>
</action>有什么解决办法吗?
发布于 2014-01-09 06:32:59
据我所知,不可能同时归还多个东西。一旦完成所有的tiles操作,浏览器将只需要一件事情,即JSON或HTML。
我可以想出两种方法来做到这一点:双重请求(一种针对每种结果类型)或使用一种来生成另一种(获取JSON并使用JavaScript在客户端上构造HTML )。
你想要达到什么目的,你需要两个结果?
为Tiles+JSON创建一个新的结果类型&使用它..。不能在结果标记中定义两个结果类型
发布于 2014-01-09 06:13:51
发布于 2015-07-14 18:06:18
我也面临着同样的问题。我的最后答案是:你不需要它。您必须定义两个不同的结果,一个使用"tiles“,另一个使用"json”。在我的例子中,出现了使用jTable的问题。你需要这样的东西:
<action name="seeCampDataGrid">
<result name="get" type="tiles">getCampData</result>
</action> <!-- this load the jsp, probably with no data -->
<action name="*CampData" method="{1}" class="com.contaque.monitor.CampAction">
<result name="get" type="json" />
</action> <!-- this will load data within the jsp. No jsp is needed. -->https://stackoverflow.com/questions/21012771
复制相似问题