Struts2+JSON+jQuery實現異步交互數據時選擇要序列化的屬性(二使用XML配置方式)
Posted on 2010-07-29 16:29 平常心 閱讀(944) 評論(1) 編輯 收藏 所屬分類: Struts2更多博客請查看:http://www.v5cn.cn
只需在XML配置就可以了,配置方式是:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.1//EN" "http://struts.apache.org/dtds/struts-2.1.dtd">
<struts>
<package name="jsons" extends="json-default" namespace="/">
<action name="getJSON" class="test.json.Users">
<result name="success" type="json">
<!-- excludeProperties表示不包含的屬性(可以使用正則表達式匹配) -->
<param name="excludeProperties">
id,userName
</param>
<!-- includeProperties表示包含序列化的屬性(可以使用正則表達式匹配) -->
<param name="includeProperties">
pwd,address
</param>
</result>
</action>
</package>
</struts>
默認情況下Struts2插件的序列化是從Action開始的如果需要序列化從指定的方式開始請使用:
<!-- 這樣序列化工作就從birthday開始了 -->
<param name="root">
birthday
</param>
Struts2JSONPlugin使用文檔.pdf
只需在XML配置就可以了,配置方式是:






















