httpClient请求服务器报javax.xml.stream.XMLStreamException: ParseErro错误
今天用httpClient获取服务器端的xml数据时,报如下错误
00123:javax.xml.stream.XMLStreamException: ParseError at [row,col]:[2,47]
Message: Invalid byte 2 of 2-byte UTF-8 sequence.
at com.sun.org.apache.xerces.internal.impl.XMLStreamReaderImpl.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLStreamReaderImpl.getElementText(Unknown Source)
是服务器传过来有中文造成的(服务器是UTF-8格式),改成英文。正常显示。后在网上了些资料,将PostMethod的getRequestCharSet()方法重写,返回UTF-8编码,还是不行。后来发现代码文件时gbk的,修改为UTF-8.在执行程序,结果显示正常!