第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

代碼在下面,頭炸了

代碼在下面,頭炸了

冉冉說 2018-12-06 17:44:08
package per.sww.four.foursenver; import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; @XmlRootElement(name="book") public class Book { public Book(){ super(); } private String category; private Title title; private String author; private String year; private String price; @XmlAttribute(name="category") public String getCategory() { return category; } public void setCategory(String category) { this.category = category; } @XmlElement(name="title") public Title getTitle() { return title; } public void setTitle(Title title) { this.title = title; } @XmlElement(name="author") public String getAuthor() { return author; } public void setAuthor(String author) { this.author = author; } @XmlElement(name="year") public String getYear() { return year; } public void setYear(String year) { this.year = year; } @XmlElement(name="price") public String getPrice() { return price; } public void setPrice(String price) { this.price = price; } } package per.sww.four.foursenver; import java.io.File; import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBException; import javax.xml.bind.Unmarshaller; public class ReadBook { public static void main(String[] args){ try{ JAXBContext jc=JAXBContext.newInstance(Bookstore.class); Unmarshaller u=jc.createUnmarshaller(); Bookstore b=(Bookstore)u.unmarshal(new File("D:"+File.separator+"3.xml")); for(Book book:b.getBooks()){ for(Title title:b.getTitles()){ System.out.println(title.getLang()); } System.out.println(book.getTitle()); System.out.println(book.getAuthor()); System.out.println(book.getYear()); System.out.println(book.getPrice()); } }catch(JAXBException e){ e.printStackTrace(); } } } package per.sww.four.foursenver; import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlRootElement; @XmlRootElement(name="title ") public class Title { public Title(){ super(); } private String lang; @XmlAttribute(name="lang") public String getLang() { return lang; } public void setLang(String lang) { this.lang = lang; } } package per.sww.four.foursenver; import java.util.List; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElements; import javax.xml.bind.annotation.XmlRootElement; @XmlRootElement(name="bookstore ") public class Bookstore { public Bookstore(){ super(); } List<Book> books; @XmlElements(value={@XmlElement(name="book",type=Book.class)}) public List<Book> getBooks() { return books; } public void setBooks(List<Book> books) { this.books = books; } List<Title> titles; @XmlElements(value={@XmlElement(name="title",type=Title.class)}) public List<Title> getTitles() { return titles; } public void setTitles(List<Title> titles) { this.titles = titles; } } ? <?xml version="1.0" encoding="ISO-8859-1"?> <bookstore> <book category="children"> <title lang="en">Harry Potter</title> <author>J K. Rowling</author> <year>2005</year> <price>29.99</price> </book> <book category="cooking"> <title lang="en">Everyday Italian</title> <author>Giada De Laurentiis</author> <year>2005</year> <price>30.00</price> </book> <book category="web"> <title lang="en">Learning XML</title> <author>Erik T. Ray</author> <year>2003</year> <price>39.95</price> </book> <book category="web"> <title lang="en">XQuery Kick Start</title> <author>James McGovern</author> <author>Per Bothner</author> <author>Kurt Cagle</author> <author>James Linn</author> <author>Vaidyanathan Nagarajan</author> <year>2003</year> <price>49.99</price> </book> </bookstore> ? 現(xiàn)在的問題是它報(bào)錯(cuò),我剛學(xué)也看不懂錯(cuò)誤,搞了半天也沒搞清楚是什么問題,求解決,代碼完全附上也不多,多幫幫俺吧
查看完整描述

3 回答

?
眼眸繁星

TA貢獻(xiàn)1873條經(jīng)驗(yàn) 獲得超9個(gè)贊

哼,報(bào)錯(cuò)頁面都不給

查看完整回答
反對(duì) 回復(fù) 2018-12-16
?
阿晨1998

TA貢獻(xiàn)2037條經(jīng)驗(yàn) 獲得超6個(gè)贊

@XmlRootElement(name="bookstore ") 多了個(gè)空格

查看完整回答
反對(duì) 回復(fù) 2018-12-16
?
慕娘9325324

TA貢獻(xiàn)1783條經(jīng)驗(yàn) 獲得超4個(gè)贊

1.類Book的注解 @XmlRootElement(name="book") 的root根節(jié)點(diǎn)應(yīng)該是 @XmlRootElement(name="bookstore"),如上所說。

2.另外類ReadBook中 Bookstore b=(Bookstore)u.unmarshal(new File("D:"+File.separator+"3.xml")); 調(diào)試下路徑,然后直接在我的電腦中打開看看,是否存在(問題異常:handleEvent(Unknown Source) 。

?注:慢慢逐步排查,不要著急,可以百度下 。

查看完整回答
反對(duì) 回復(fù) 2018-12-16
  • 3 回答
  • 0 關(guān)注
  • 540 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)