0

内部列表不作为 JSON 字符串返回。仅返回第一个数据列表...

有没有办法将所有数据作为 JSON 字符串获取?

------我的方法----------

@RequestMapping(value="/mainreservationChart", method = RequestMethod.GET)
public ModelAndView getMRChartData(@ModelAttribute ("ReservationSummaryRQDTO") ReservationSummaryRQDTO search){

    ReservationSummaryDTO returnDataDTO = new ReservationSummaryDTO();

    MainReservationChartWSImpl wsImpl = MRWSUtil.getInstance().getWS_ServicePort();

    search.setHotelCode("BBH");
    search.setReportDate(toXmlDateGMT(new Date()));

    returnDataDTO = wsImpl.getReservationSummary(search);

    Map<String, Object> model = new HashMap<String, Object>();
    model.put("status", true);
    model.put("hotelCode", returnDataDTO.getHotelCode());
    model.put("summary", returnDataDTO.getSummaryMonth());
    model.put("data", returnDataDTO);

    return new ModelAndView("jsonView", model);

}

DTO

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "reservationSummaryDTO", propOrder = {
    "hotelCode",
    "summaryMonth"
})
public class ReservationSummaryDTO {

    protected String hotelCode;
    @XmlElement(nillable = true)
    protected List<SummaryMonthDTO> summaryMonth;
}

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "summaryMonthDTO", propOrder = {
    "month",
    "summaryType"
})
public class SummaryMonthDTO {

    protected String month;
    @XmlElement(nillable = false)
    protected List<SummaryTypeDTO> summaryType;
}

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "summaryTypeDTO", propOrder = {
    "date",
    "displaySequence",
    "total",
    "typeCode"
})
public class SummaryTypeDTO {

    @XmlElement(nillable = true)
    protected List<SummaryDateDTO> date;
    protected Integer displaySequence;
    protected Double total;
    protected String typeCode;
4

1 回答 1

0

尝试这个

@RequestMapping(value="/mainreservationChart", method = RequestMethod.GET, headers = "Accept=application/json") 
于 2013-05-09T15:11:05.660 回答