Получение искаженного ответа при вызове API Java, развернутого на сервере Windows с помощью jodd.http, несмотря на указаJAVA

Программисты JAVA общаются здесь
Ответить
Anonymous
 Получение искаженного ответа при вызове API Java, развернутого на сервере Windows с помощью jodd.http, несмотря на указа

Сообщение Anonymous »


I'm encountering an issue when remotely invoking a Java API deployed on a Windows server. While I can successfully make the call using Apipost(A software similar to Postman) and receive data encoded in UTF-8 without any garbled characters, I face a problem when invoking it using the following code snippet:

public static String post(String url, String jsonStr) { HttpResponse resp = HttpRequest.post(url) .connectionTimeout(60000) .timeout(60000) .contentType("application/json", StandardCharsets.UTF_8.toString()) .bodyText(jsonStr, "application/json", "utf-8") .charset(StandardCharsets.UTF_8.toString()) .send(); resp.charset(StandardCharsets.UTF_8.toString()); return resp.bodyText(); } I'm using jodd.http for this purpose, and here's the Maven dependency:

org.jodd jodd-http 6.3.0 The following image is a screenshot of me calling the API using Apipost(A software similar to Postman). enter image description here enter image description here The following is a screenshot of the log for my service invocation interface. enter image description here Despite specifying UTF-8 encoding, I receive garbled text in the response. What could be causing this issue?

I expected that by specifying UTF-8 encoding and ensuring proper encoding on the server side, the response would display correctly without any garbled characters. However, despite these efforts, I continued to receive garbled text in the response.I'm hoping to receive assistance from experts in resolving this issue. ( ̄▽ ̄)~*


Источник: https://stackoverflow.com/questions/780 ... rver-using
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «JAVA»