繁体   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