Struts 2 json导致数组列表

时间:2015-09-28 10:55:11

标签: java arrays json regex struts2

我有一个ArrayList数组ArrayList<[obj1,obj2]>。这里obj1obj2是不同的Java实体,这个列表由HQL查询返回。

如何遍历struts.xml文件中的此列表以将其作为JSON结果发送?

我试过下面的组合,但没有运气:

  1. ^itemList\[\d+\]\.^\[\0+\].id - &gt; id是实体的属性
  2. ^itemList\[\d+\]\.\0\.id
  3. ^itemList\[\d+\]\.co.id - &gt; co = hql中的实体别名
  4. ^itemList\[\d+\]\[0].id
  5. ^itemList\[\d+\]\.\[\0+\].id
  6. ^itemList\[\d+\]\.[0].id
  7. 编辑:

    我在struts.xml中使用了它,如下所示;

    <action name="list-view-op-cost-management_cons"  class="com.eves.aixis.s2.action.billing.ConsignmentBillingGridAction" method="listViewOperationalCostForManagement">
                <result type="json">
                    <param name="ignoreHierarchy">false</param>
                    <param name="includeProperties">
                        viewType,
                        searchType,
                        searchValue,
                        service,
                        page,
                        total,
                        records,
                        **^itemList\[\d+\]\.^\[\0+\].id,**
                        reqaction_,
                        actionResult,
                        ^errorList\[\d+\]
    
                    </param>
                </result>
            </action>
    

    编辑:

    Obj1 =寄售(商业实体)

    with fileds;

    private Integer id;
        private String consignmentNo;
        private Customer sender;
        private Contact senderContact;
        private Pickup pickupRef;
        private Receiver receiver;
        private List<Invoice> invoiceList;
        private ConsignmentStatus consignmentStatus;
        private Boolean invoiceToReiver;
        private String deliveryInstruction;
        private String customerReference;
        private List<PackageDescription> packageDescription;// actual package info
        private List<PackageDescription> custPackage;//use in ecp (external customer portal) and use in inquiry given customer package details
        private List<PackageDescription> revProtPackages;//revenue protection packages
    
        private Receiver deliveryAddress;
        private List<ConsignmentTrack> connoteTrack;
        private ProductType productType;
        private List<Commodity> commodities;
        private PreBriefDeskVerify briefDeskVerify;
    

    和obj2 = SalesOrder(商业实体)

    with fileds;

    private Long id;
        private SalesOrderType salesItemType;
    
        private Consignment salesItem;  
    
        private MasterAirwayBill mawb; 
        private Pickup pickupSI;
        private Delivery deliverySI;
    
    
        private WHSalesItem whSalesItem;
    
    
        private Job job;
        private SCMBillingState billingState;
    
    
        private Tariff tariff; 
    
        private Tariff tariffForPrinciples; 
    
    
        private List<SalesOrderLineItem> salesOrderItemList;
        private String remarks;
        private SalesOrderStatus salesOrderStatus;
    

1 个答案:

答案 0 :(得分:0)

param <android.support.design.widget.FloatingActionButton [...] app:layout_behavior="your.package.name.FloatingActionButtonBehavior"/> 包含一个正则表列表,用于匹配serializable到JSON对象的属性。此正则表达式应与您的属性名称匹配,请尝试

includeProperties

如果您只想要^itemList.*$ 属性,那么您可以尝试

id