[英]Type safety: Unchecked cast from Object to JAXBElement<User>
我有一個演員的概率
JAXBElement<User> jaxbElement = (JAXBElement<User>)unmarshaller.unmarshal(sr);
它不起作用,eveybody可以幫助我嗎?
我不能這樣做:我告訴你我的代碼:
StringReader sr = new StringReader(this.message);
JAXBElement<Utilisateur> jaxbElement = (JAXBElement<Utilisateur>) unmarshaller.unmarshal(sr);
如果我這樣做,我有一個錯誤,因為我使用StringReader:
JAXBElement<User> jaxbElement = unmarshaller.unmarshal(sr, User.class);
如果要避免編譯器警告,可以使用帶有Class
參數的unmarshal方法之一。
JAXBElement<User> jaxbElement = unmarshaller.unmarshal(sr, User.class);
注意
您的代碼應該在您的問題中完全正常運行。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.