consumes=“charset=utf-8”无法使用spring引导

np8igboo  于 2021-07-24  发布在  Java
关注(0)|答案(1)|浏览(564)

我传入requestparam一个值,例如“fré使“它变成”frã©问“请问我怎样才能解决这个问题?”。
这是我的代码和运行它的异常

@RequestMapping(value = "{subfamilyId}/docs", method = RequestMethod.GET, consumes="charset=utf-8")
public void series(@PathVariable("subfamilyId") String subfamilyId,
                   @RequestParam(value = "columns", required = false) String columns,
                   @RequestParam(value = "searchedValues", required = false) String searchedValues,
                   @RequestParam(value = "excludedValues", required = false) String excludedValues,
                   @RequestParam(value = "format", required = false, defaultValue = "csv") String format,
                   @RequestParam(value = "pretty", required = false) boolean pretty,
                   @RequestParam(value = "size", required = false, defaultValue = "100") int size,
                   @RequestParam(value = "scroll_id", required = false) String scrollId,
                   HttpServletResponse response) throws Exception {}

我得到一个例外:

Caused by: org.springframework.util.InvalidMimeTypeException: Invalid mime type "charset=utf-8": does not contain '/'
at org.springframework.util.MimeTypeUtils.parseMimeType(MimeTypeUtils.java:231) [spring-core-4.2.4.RELEASE.jar:4.2.4.RELEASE]
at org.springframework.http.MediaType.parseMediaType(MediaType.java:382) [spring-web-4.2.4.RELEASE.jar:4.2.4.RELEASE]
... 48 more

你能帮帮我吗?

mwecs4sa

mwecs4sa1#

您应该先指定媒体类型

consumes = {"text/plain; charset=UTF-8", "application/*; charset=UTF-8"}

相关问题