我正在尝试使用Spring从web加载多语言XML文件。不幸的是,Spring似乎正在将其视为某种其他形式的编码。下面是我配置的相关部分:
<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配置中做错了什么。有什么建议吗?
发布于 2014-08-23 22:08:59
您应该在charset上设置content-type;参见这里。
https://stackoverflow.com/questions/25466127
复制相似问题