`
zhouchaofei2010
  • 浏览: 1085637 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

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集合对象中的元素

 

 

 

 

 

 

 

 

分享到:
评论
6 楼 zhouchaofei2010 2013-06-25  
qswdit 写道
应该是一个list 对象不做任何处理



list 好处理,但是set 没处理过,也不知道怎么处理。为了性能效率,通常需要对list处理的,只需得到我们想要list集合中元素的的具体属性值。
5 楼 zhouchaofei2010 2013-06-25  
qswdit 写道
求解释! 我指向返回一个完全的json 怎么搞!

什么意思,是指简化json么?
4 楼 qswdit 2013-06-25  
应该是一个list 对象不做任何处理
3 楼 qswdit 2013-06-25  
求解释! 我指向返回一个完全的json 怎么搞!
2 楼 zhouchaofei2010 2012-02-29  
难问题啊,没试过。
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.*
这不是我需要的

相关推荐

Global site tag (gtag.js) - Google Analytics