gpt4 book ai didi

java - 服务器返回 HTTP 响应代码 : 500 when we are sending Arabic language content

转载 作者:行者123 更新时间:2023-12-01 10:54:45 25 4
gpt4 key购买 nike

我们正在向服务器发送 HTTPURLRequest。

当我们发送英语内容时,它工作正常。但是,当我们发送阿拉伯语内容时,我们得到

Server returned HTTP response code: 500 

我们编写了以下代码

connection = (HttpURLConnection) url.openConnection();          

connection.setRequestMethod("POST");
connection.setRequestProperty("Content-Type", "text/xml; charset=utf-8");
connection.setRequestProperty("Content-Length", "" + Integer.toString(SendRequest.getBytes().length));
connection.setUseCaches(false);
connection.setDoInput(true);
connection.setDoOutput(true);
DataOutputStream dataout = new DataOutputStream(connection.getOutputStream());
dataout.writeBytes(SendRequest);
dataout.flush();
dataout.close();
BufferedReader bufferreader = new BufferedReader(new InputStreamReader(connection.getInputStream(), "utf-8"));

当我使用connection.getInputStream()时,我收到 500 错误我们也使用utf-8。但是,仍然收到错误谁能帮帮我

最佳答案

您可以使用库来转义特殊字符:

StringEscapeUtils.escapeJava("هولاء كومو")

该类(class)可在: Commons Lang from Apache 上找到。

希望这有帮助!

关于java - 服务器返回 HTTP 响应代码 : 500 when we are sending Arabic language content,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33675027/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com