TOMCAT XMLのパーサーでのエラー TOMCATのデフォルトがUTF-8ではないから

// ドキュメントビルダーファクトリを生成
DocumentBuilderFactory dbfactory = DocumentBuilderFactory.newInstance();
// ドキュメントビルダーを生成
DocumentBuilder builder = dbfactory.newDocumentBuilder();
// パースを実行してDocumentオブジェクトを取得
ByteArrayInputStream stream = new ByteArrayInputStream(xml.getBytes());
Document doc = builder.parse(stream);

ここでのエラー

com.sun.org.apache.xerces.internal.impl.io.MalformedByteSequenceException: 1バイトのUTF-8シーケンスのバイト1が無効です。

この場合は、

java7w.exe を起動して、Java Optionsに「-Dfile.encoding=UTF8」を追加する。

Comments are closed.

全自動マージャン卓
10万円未満で買える
折りたたんで収納


会社に1台

AMAZON