struts-plugin resulttype 参数

来源:互联网 发布:java语言入门书 编辑:程序博客网 时间:2024/05/19 13:28

来源 https://cwiki.apache.org/confluence/display/WW/JSON%20Plugin

Excluding properties

A comma-delimited list of regular expressions can be passed to the JSON Result and Interceptor, properties matching any of these regular expressions will be ignored on the serialization process:

<!-- Interceptor fragment -->
<interceptor-ref name="json">
  <param name="enableSMD">true</param>
  <param name="excludeProperties">
    login.password,
    studentList.*\.sin
  </param>
</interceptor-ref>

Including properties

A comma-delimited list of regular expressions can be passed to the JSON Result to restrict which properties will be serialized. ONLY properties matching any of these regular expressions will be included in the serialized output.

 Note
Exclude property expressions take precedence over include property expressions. That is, if you use include and exclude property expressions on the same result, include property expressions will not be applied if an exclude exclude property expression matches a property first.

<!-- Result fragment -->
<result type="json">
  <param name="includeProperties">
    ^entries\[\d+\]\.clientNumber,
    ^entries\[\d+\]\.scheduleNumber,
    ^entries\[\d+\]\.createUserId
  </param>
</result>

Root Object
Use the "root" attribute(OGNL expression) to specify the root object to be serialized.

<result type="json">
  <param name="root">
    person.job
  </param>
</result>


The "root" attribute(OGNL expression) can also be used on the interceptor to specify the object that must be populated, make sure this object is not null.

<interceptor-ref name="json">
  <param name="root">bean1.bean2</param>
</interceptor-ref>

原创粉丝点击