轉自:http://wangquanhpu.iteye.com/blog/1461750
1, ignoreHierarchy 參數:表示是否忽略等級,也就是繼承關系,比如:TestAction 繼承於 BaseAction,那么 TestAction 中返回的 json 字符串默認是不會包含父類 BaseAction 的屬性值,ignoreHierarchy 值默認為 true,設置為 false 后會將父類和子類的屬性一起返回。
- <result type=”json”>
- <paramname=”ignoreHierarchy”>false</param>
- </result>
2, excludeNullProperties 參數:表示是否去掉空值,默認值是 false,如果設置為 true 會自動將為空的值過濾,只輸出不為空的值。
- <result ype=”json”>
- <paramname=”excludeNullProperties”>true</param>
- </result>
3, root 參數:從返回結果中根據 ognl 表達式取出你需要輸出的結果。
只輸出 person 對象的 name 屬性值,配置如下:
- <result type=”json”>
- <param name=”root”>person.name</param>
- </result>
4, includeProperties 參數:輸出結果中需要包含的屬性值,這里正則表達式和屬性名匹配,可以用 “,” 分割填充多個正則表達式。
- <result type=”json”>
- <param name=”includeProperties”>person.*, person\.name</param>
- </result>
5, excludeProperties 參數:輸出結果需要剔除的屬性值,也支持正則表達式匹配屬性名,可以用 “,” 分割填充多個正則表達式,類同 includeProperties 參數。