gpt4 book ai didi

json - Json struts2 插件中的 includeProperties 不起作用

转载 作者:行者123 更新时间:2023-12-02 12:37:00 25 4
gpt4 key购买 nike

我正在使用struts2-json-plugin-2.2.3.jar。并尝试序列化类的 filterList 属性,如下所示:

struts.xml代码

<action name="jsonUserFilterListAction"  class="com.my.fitnessb.actions.UserArticlesAction" method="filterList">
<result name="success" type="json">
<param name="includeProperties">filterList</param>
</result>
</action>

Action 类

public class UserArticlesAction extends ActionSupport implements SessionAware, ServletRequestAware {

private List<FilterType> filterList;
HttpServletRequest request;

public String filterList() {
filterList = new ArrayList<FilterType>();
filterList.add(new FilterType(10, "Latest Articles"));
filterList.add(new FilterType(1, "Trending Articles"));
filterList.add(new FilterType(2, "Top Rated Articles"));
filterList.add(new FilterType(3, "Most Viewd Atricles"));
filterList.add(new FilterType(4, "All Atricles"));
return SUCCESS;
}
//setter & getter of filterList
}

但我无法获取 FilterType 类的此属性。

最佳答案

假设 FilterType 中的字段名为 iddesc

尝试

<param name="includeProperties">
filterList\[\d+\]\.id,
filterList\[\d+\]\.desc
</param>

关于json - Json struts2 插件中的 includeProperties 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14433349/

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