How to serialize superclass attributes to JSON format in Struts2

  • 2020-04-01 01:39:49
  • OfStack

Because of the use of Extjs4 in the front end of the project, list paging needs to return three parameters: totalCount (total number of records), start (start position), and limit (number of bars per page). Since there are many grids in the project that need to be paged, if you want to put the page information into a separate Action class, you need the paged Action to directly inherit that class. The original struts.xml configuration is as follows:


<package name="admin" namespace="/admin" extends="json-default">
         <action name="admin_*_*" class="com.sxpt.action.admin.{1}Action"
         method="{2}">
             <result name="slist" type="json">
             </result>
         </action>
     </package>

However, the struts-json plug-in does not serialize the parent class by default, that is, it cannot return the parent class properties

<param name="ignoreHierarchy">false</param>


Related articles: