我正在使用struts2-json-plugin-2.2.3.jar
。並試圖序列化類的filterList
屬性是這樣的:在Json中includeProperties struts2插件不工作
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
}
,但我不能夠得到過濾式類的這個屬性。
就可以得到價值,如果帕拉姆'includeProperties'未使用? – Quincy
如果不使用參數includeProperties,我將得到seralize action class中的所有屬性 –