0

どうして違うのかわかりません。不一致は、クライアントではサーバーよりも多くのスペースがあるため、サーバーで解析しようとすると次のようになります 。DOMの解析--org.xml.sax.SAXParseException コードは次のとおりで、メッセージは次のように含まれています。コメント:

Element rootElement = document.createElement(MyServer.NEW_PLAYER_CONNECTION_REQUEST);
    Element participantTypeElement = document.createElement(MyServer.PARTICIPANT_TYPE);
    Text textParticipantType = document.createTextNode(participantType);
    participantTypeElement.appendChild(textParticipantType);
    rootElement.appendChild(participantTypeElement);
    document.appendChild(rootElement);
    StringWriter sw = new StringWriter();
    TransformerFactory tFactory = TransformerFactory.newInstance();
    Transformer transformer;
    try {
        transformer = tFactory.newTransformer();
        DOMSource source = new DOMSource(document);
        StreamResult result = new StreamResult(sw);
        transformer.transform(source, result);
    } catch (TransformerConfigurationException e) {
        e.printStackTrace();
    }
    catch (TransformerException t) {
        t.printStackTrace();
    }
    try {
        conn.setRequestMethod("POST");
    } catch (ProtocolException e) {
        e.printStackTrace();
    }
    conn.setRequestProperty("Content-Type", "text/xml");
    //conn.setRequestProperty("Content-Length", "" +  8);
    conn.setRequestProperty("Content-Language", "en-US");  
4

1 に答える 1

0

ただの仮定ですが、UTF-8と他のASCii文字セットの間の読み取り(変換以上)は、ストリームを介した文字数値の読み取り/レンダリングで軽微な障害を引き起こす可能性があります。2つのポイント間の文字セットが問題である可能性があります。

于 2012-08-18T08:55:48.083 に答える