日期:2014-05-16  浏览次数:20326 次

struts2 jsonplugin includeProperties 对list集合的正则配置

jsonplugin?? 0.32?? 0.34 官方下载? http://code.google.com/p/jsonplugin/

?

文档:http://code.google.com/p/jsonplugin/wiki/Documentation

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

?

Excluding properties

<!-- Result fragment -->
<result type="json">
  <param name="excludeProperties">
    login.password,
    studentList.*\.sin
  </param>
</result>

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

?

Including properties

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

?

对集合?listAttachment.*, listAttachment\[\d+\] 含义是不同的

listAttachment.*, 指listAttachment集合对象本身

listAttachment\[\d+\] 指listAttachment集合对象中的元素

?

?

?

?

?

?

?

?

1 楼 fandia 2012-02-29  
如果返回的JSON是个集合,而且集合中包含着集合,怎么配置result中的includeProperties??

如返回的teachers是一个List<Teacher>,包括着studentSet,studentSet是一个Set<Student>

如果只想取得studentSet中的每一个Student对象的姓名(student.name),includeProperties怎么配置?

我试着如下,不行,什么都不会返回,感觉从逻辑上应该没有错误.
teachers\[\d+\]\.studentSet\[\d+\]\.name

如果是这样,会返回所有的Student对象属性
teachers\[\d+\]\.studentSet.*
这不是我需要的
2 楼 zhouchaofei2010 2012-02-29  
难问题啊,没试过。