【发布时间】:2022-02-03 07:53:31
【问题描述】:
我有一个 JavaFX 应用程序和一个 Java 服务器,我正在尝试使用 JSON 发送一个 post 方法,但是当我这样做时,我从服务器收到此错误
Resolved [org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: Invalid UTF-8 middle byte 0x77; nested exception is com.fasterxml.jackson.databind.JsonMappingException: Invalid UTF-8 middle byte 0x77
at [Source: (PushbackInputStream); line: 1, column: 209] (through reference chain: java.util.ArrayList[0]->pwsztar.edu.pl.project_kino.dto.Film["opis"])]
我的发帖请求如下所示
String json = new Gson().toJson(filmsToDelete);
System.out.println(json);
var request = new HttpPost("http://localhost:8080/api/v1/removeFilm");
request.setHeader("Content-type", "application/json;charset=UTF-8");
request.setEntity(new StringEntity(json));
HttpResponse response = client.execute(request);
System.out.println(response.getStatusLine());
filmToDelete 是 Film 对象的数组列表。
这是服务器上的我的控制器方法
@PostMapping(path = "removeFilm")
public void removeFilms(@RequestBody ArrayList<Film> filmsToRemove){
filmService.printFilms(filmsToRemove);
}
所以我想知道问题出在哪里,也许我该如何解决。如果有任何其他信息,请告诉我
【问题讨论】: