gpt4 book ai didi

java - includeProperties 不起作用?

转载 作者:行者123 更新时间:2023-11-30 08:27:22 24 4
gpt4 key购买 nike

struts.xml:

<action name="findTspNameIdMap"
class="cdot.oss.cmsat.gma.struts.ConfigureTspThresholdAction" method="findTspNameIdMap">

<result name="success" type="json">
<param name="includeProperties">result,tspNameIdMap.*</param>
</result>

<result name="error">pages/Error.jsp</result>

</action>

Action 类:

public class ConfigureTspThresholdAction extends ActionSupport implements SessionAware, ModelDriven<GmaThresholdParameter>{


private Map<String,Object> session;
private String operatorId;

private Map<String,String> tspNameIdMap;
private String result = "success";

//private List<String> thresholdParameters;
GmaThresholdParameter gmaThresholdParameters = new GmaThresholdParameter();

我对操作执行 AJAX 调用,当我在 Firebug 中检查 JSON 响应时,它是:{} .但是,如果我这样做 <param name="root">tspNameIdMap</param>它有效但无效 includeProperties .

早些时候它可以工作,但我做了一些代码更改(与上面的代码部分无关)并且它停止工作了。代码更改包括实现 ModelDriven对于 POJO。

为什么不工作?有帮助吗?

最佳答案

已解决:

struts.xml:

   <result name="success" type="json">
<param name="root">action</param>
<param name="includeProperties">result,tspNameIdMap.*</param>
</result-type>

我添加了 <param name="root">action</param>到我的代码,它解决了问题。

从我解决的地方引用这个链接:http://blog.mattsch.com/2011/04/14/things-discovered-in-struts-2/

Since Struts 2.2.3 the root object is always considered to be the model if the action is model >driven. This means that when creating the JSON request only the model will get serialized. In >some cases one might use model driven for receiving requests and send something else in the >response. Then the root object has to be changed. This can be done by setting the root >parameter as shown above.

关于java - includeProperties 不起作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20918867/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com