2010-11-09 38 views
6

Chúng tôi có mã JAXB/Java bên dưới. Điều này làm việc tốt cho đến khi chúng tôi thay đổi List<JQGridTO> rows thành List<? extends JQGridTO> rows.JAXB và các bộ sưu tập có chứa generics

Khi chúng tôi thực hiện thay đổi mà chúng tôi nhận được lỗi này:

Constructor threw exception; nested exception is com.sun. xml.bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions Property rows appears in @XmlType.propOrder, but no such property exists. Maybe you meant records? this problem is related to the following location: at com.me.ui.service.JQGridJsonRoot

Tại sao chúng ta nhận được lỗi này? Bạn không thể sử dụng Generics như chúng tôi đã làm (ví dụ: specifing ? extends XXX)?

@XmlRootElement 
@XmlType(name = "", propOrder = { 
     "records", 
     "page", 
     "total", 
     "rows" 
}) 
public class JQGridJsonRoot { 
    int total; //total pages for the query 
    int page; //current page of the query 
    int records; //total number of records for the query 
    List<? extends JQGridTO> rows 
    ... 

Trả lời

Các vấn đề liên quan