簡體   English   中英

Spring Integration http出站網關和UTF-8

[英]Spring Integration http outbound-gateway and UTF-8

我正在嘗試使用Spring Integration從Web加載多語言XML文件。 不幸的是,Spring Integration似乎將其視為其他形式的編碼。 這是我的配置的相關部分:

<int-http:outbound-gateway id="example"
    request-channel="requests"
    url="http://localhost/test.xml"
    http-method="GET"
    expected-response-type="java.lang.String"
    charset="UTF-8"
    reply-timeout="1234"
    reply-channel="replies"/>

我檢索的文本被視為ISO-8859-1。 我之所以這樣認為,是因為如果我重新編碼然后解碼,我會得到正確的文本。 像這樣:

public void handleReply(String rawXML) {
    String forRealzies = "";
    try {
        String hack1 = URLEncoder.encode(rawXML, "ISO-8859-1");
        forRealzies = URLDecoder.decode(hack1, "UTF-8");
    } catch(UnsupportedEncodingException e1) {
        e1.printStackTrace();
    }
    // forRealzies now has the properly encoded String
}

我真的希望我在XML配置中做錯了什么。 有什么建議么?

您應該在content-type上設置charset 這里

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM