<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
    "http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
    <package name="json" extends="json-default" namespace="/test">
        <action name="testByAction"
            class="cn.ysh.studio.struts2.json.demo.action.UserAction" method="testByAction">
            <result type="json">
                <!-- 这里指定将被Struts2序列化的属性,该属性在action中必须有对应的getter方法 -->
                <!-- 默认将会序列所有有返回值的getter方法的值,而无论该方法是否有对应属性 -->
                <param name="root">dataMap</param>
                <!-- 指定是否序列化空的属性 -->
                <!--
                <param name="excludeNullProperties">true</param>
                -->
                <!-- 这里指定将序列化dataMap中的那些属性 -->
                <!--
                <param name="includeProperties">
                     userList.*
                </param>
                 -->
                <!-- 这里指定将要从dataMap中排除那些属性,这些排除的属性将不被序列化,一半不与上边的参数配置同时出现 -->
                <!--
                <param name="excludeProperties">
                     SUCCESS
                </param>
                -->
            </result>
        </action>
    </package>
    <package name="default" extends="struts-default" namespace="/">
        <action name="testJSONFromActionByGeneral"
            class="cn.ysh.studio.struts2.json.demo.action.UserAction" method="doAction">
        </action>
        <action name="testByJSP"
            class="cn.ysh.studio.struts2.json.demo.action.UserAction" method="testByJSP">
            <result name="success">/actionJSP.jsp</result>
        </action>
    </package>
</struts>

 

 

http://yshjava.iteye.com/blog/1333104