简体   繁体   English

Spring Integration http出站网关和UTF-8

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

I'm trying to use Spring Integration to load a multilingual XML file from the web. 我正在尝试使用Spring Integration从Web加载多语言XML文件。 Unfortunately, it appears that Spring Integration is treating it as some other form of encoding. 不幸的是,Spring Integration似乎将其视为其他形式的编码。 Here's the relevant part of my config: 这是我的配置的相关部分:

<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"/>

The text I retrieve is treated like it's ISO-8859-1. 我检索的文本被视为ISO-8859-1。 The reason I believe this, is because if I recode and then decode, I get the correct text. 我之所以这样认为,是因为如果我重新编码然后解码,我会得到正确的文本。 Something like this: 像这样:

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
}

I'm really hoping I'm doing something wrong in the XML config. 我真的希望我在XML配置中做错了什么。 Any suggestions? 有什么建议么?

You should set the charset on the content-type ; 您应该在content-type上设置charset see here . 这里

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Spring Integration单元测试http:outbound-gateway - Spring Integration unit test http:outbound-gateway Spring Integration-网址变量在http:outbound-gateway中不起作用 - Spring Integration - url-variable not working in http:outbound-gateway Spring Integration http:outbound-gateway“没有合适的HttpMessageConverter” - Spring Integration http:outbound-gateway “no suitable HttpMessageConverter” 在int-ws:outbound-gateway上通过Spring集成处理Http错误 - Handle Http errors with spring integration on int-ws:outbound-gateway Spring Integration Java DSL - 如何调用int-http:outbound-gateway? - Spring Integration Java DSL - How to invoke int-http:outbound-gateway? Spring Integration:如何使用http:outbound-gateway将字节数组作为POST参数发送? - Spring Integration: how to send a Byte Array as POST parameter with an http:outbound-gateway? 如何在Spring集成中使用JAVA配置创建http outbound-gateway? - How can I create http outbound-gateway with JAVA config in Spring integration? Spring集成出站网关想像动态一样使用URL - Spring integration outbound-gateway want to use URL as dynamic like Spring Integration通过出站网关递归获取FTP文件 - Spring Integration get FTP files recursively with outbound-gateway Spring集成dsl:http出站网关 - Spring integration dsl: http outbound gateway
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM