總是出現(xiàn)這個異常怎么回事
出這異常 怎么回事?
com.sun.org.apache.xerces.internal.impl.io.MalformedByteSequenceException: 2 字節(jié)的 UTF-8 序列的字節(jié) 2 無效。
at com.sun.org.apache.xerces.internal.impl.io.UTF8Reader.invalidByte(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.io.UTF8Reader.read(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLEntityScanner.load(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLEntityScanner.peekChar(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(Unknown Source)
at javax.xml.parsers.DocumentBuilder.parse(Unknown Source)
at com.paike.dmtest.test.DomTest.main(DomTest.java:25)
2022-03-24
foreach循環(huán)自動遍歷數(shù)組和集合的每個元素在函數(shù)后面的那個document.getElementById("fruit").value=res;前面加一個return就行了
2018-06-06
代碼實現(xiàn)的話 用java的io流對你那個xml文件重新讀寫一下 把編碼格式改了
2017-08-08
用記事本打開.xml文件,另存為時選擇編碼方式為UTF-8覆蓋原來的.xml文件,再進入eclipse->File->Refresh。
2017-07-31
這個問題我解決了,右鍵選擇Open with--Test Edit打開books.xml,是亂碼,你把亂碼刪掉,自己輸入,保存,運行時就不會報以上異常了,求采納(原因:你在創(chuàng)建文本文件時,默認編碼是ANSI,不是utf-8,所以傳進myeclips會出現(xiàn)亂碼)
2017-07-12
你在eclipse里面打開看看books.xml內容是不是亂碼?
如果是亂碼,你用其他工具打開books.xml,將沒有亂碼的內容拷貝到eclipse中的books.xml;
2017-07-07
你的xml文件編碼不是UTF-8吧,修改成UTF-8再運行一下就應該不會再報錯了