我有一个ArrayList
数组ArrayList<[obj1,obj2]>
。这里的obj1
和obj2
是不同的Java实体,这个列表是由HQL查询返回的。
如何在struts.xml
文件中循环遍历此列表以将其作为JSON结果发送?
我尝试了下面的组合,但没有运气:
^itemList\[\d+\]\.^\[\0+\].id
--> id是实体的属性^itemList\[\d+\]\.\0\.id
^itemList\[\d+\]\.co.id
--> co = hql中的实体别名^itemList\[\d+\]\[0].id
^itemList\[\d+\]\.\[\0+\].id
^itemList\[\d+\]\.[0].id
编辑:
我在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 = Consignment(Bussiness entity)
使用字段:
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(Bussiness entity)
使用字段:
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条答案
按热度按时间sc4hvdpw1#
参数
includeProperties
包含一个正则表达式列表,用于匹配可序列化到JSON对象的属性。这个正则表达式应该与你的属性名匹配,试试看如果你只想要
id
属性,那么你可以尝试