struts json result 指定需要序列化的属性
2012-06-10 16:07
330 查看
官方地址: http://struts.apache.org/2.2.3/docs/json-plugin.html
设置哪些属性要序列化哪些不需要序列化;
设置哪些属性要序列化哪些不需要序列化;
Customizing Serialization and Deserialization
Use the JSON annotation to customize the serialization/deserialization process. Available JSON annotation fields:Name | Description | Default Value | Serialization | Deserialization |
---|---|---|---|---|
name | Customize field name | empty | yes | no |
serialize | Include in serialization | true | yes | no |
deserialize | Include in deserialization | true | no | yes |
format | Format used to format/parse a Date field | "yyyy-MM-dd'T'HH:mm:ss" | yes | yes |
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:<!-- 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
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>
相关文章推荐
- Json.Net组件指定/忽略序列化字段属性技巧知识点
- struts2之使用JSON插件实现Ajax(在struts.xml中处理要序列化的属性)
- 动态结果配置:struts.xml中,<result>属性的type配置之redirectAction(请求重定向到指定的Action)
- .net中JSON序列化Object指定属性两种方法
- struts-json-plugin result中配置对象的序列化
- FastJson toString过滤指定的对象属性
- list中按照指定属性的值序列化
- struts2.xml 中result type属性说明
- java 序列化时排除指定属性
- Struts2框架中struts.xml文件的package标签的命名空间属性、默认action配置、result配置、Struts异常处理
- 在Struts2中如何将父类属性序列化为JSON格式的解决方法
- java中json字符串移除指定属性
- 指定JSON.toJSONString中实体类属性的输出顺序
- 在AspNetCore的WebApi中json序列化日期和属性名的技巧
- Struts 2中注解result type为json类型的小示例
- struts2.xml 中result type属性说明
- 【json】前台ajax序列化的多个属性拼接在一起的字符串,转化为JSONObject对象
- Action属性注入值和指定Struts 2处理的请求
- C# Json数据反序列化为Dictionary并根据关键字获取指定值
- JSON中result的root属性