博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Struts2 中 result type=”json” 的参数解释
阅读量:6860 次
发布时间:2019-06-26

本文共 933 字,大约阅读时间需要 3 分钟。

转自:http://wangquanhpu.iteye.com/blog/1461750

1, ignoreHierarchy 参数:表示是否忽略等级,也就是继承关系,比如:TestAction 继承于 BaseAction,那么 TestAction 中返回的 json 字符串默认是不会包含父类 BaseAction 的属性值,ignoreHierarchy 值默认为 true,设置为 false 后会将父类和子类的属性一起返回。 

Java代码  
  1. <result type=”json”>  
  2.     <paramname=”ignoreHierarchy”>false</param>  
  3. </result>  

2, excludeNullProperties 参数:表示是否去掉空值,默认值是 false,如果设置为 true 会自动将为空的值过滤,只输出不为空的值。 

Java代码  
  1. <result ype=”json”>  
  2.      <paramname=”excludeNullProperties”>true</param>  
  3. </result>  

3, root 参数:从返回结果中根据 ognl 表达式取出你需要输出的结果。 
只输出 person 对象的 name 属性值,配置如下: 

Java代码  
  1. <result type=”json”>  
  2.      <param name=”root”>person.name</param>  
  3. </result>  

4, includeProperties 参数:输出结果中需要包含的属性值,这里正则表达式和属性名匹配,可以用 “,” 分割填充多个正则表达式。 

Java代码  
  1. <result type=”json”>  
  2.    <param name=”includeProperties”>person.*, person\.name</param>  
  3. </result>  

5, excludeProperties 参数:输出结果需要剔除的属性值,也支持正则表达式匹配属性名,可以用 “,” 分割填充多个正则表达式,类同 includeProperties 参数。 

转载于:https://www.cnblogs.com/sharpest/p/9798605.html

你可能感兴趣的文章
Knockout.js随手记(2)
查看>>
条件注释判断IE浏览器
查看>>
Hibernate,删除对象时错误。
查看>>
C#中Cookies的读取
查看>>
冬季养生进补20招
查看>>
20179311《网络攻防实践》第四周作业
查看>>
Getting Started
查看>>
《thinking in Java》第三章 控制程序流程
查看>>
node 模块 fs-extra
查看>>
《游戏引擎架构》笔记一
查看>>
pythoy-生成器
查看>>
Redis 分布式锁进化史
查看>>
Java 集合系列05之 LinkedList详细介绍(源码解析)和使用示例
查看>>
Codeforces Round #547 (Div. 3) D
查看>>
(转)如何修正DIV float之后导致的外部容器不能撑开的问题
查看>>
Python全栈开发day9
查看>>
算法笔记 --- Insertion Sort
查看>>
子父表
查看>>
CUDA npp运动检测模块性能测试
查看>>
前端单点登录(SSO)实现方法(二级域名与主域名)
查看>>