简体   繁体   中英

consumes=“charset=utf-8” not working Spring boot

i pass in requestParam a value for example "Fréquence" it becomes "Frã©quence" how can i solve this problem please.

here is my code and the exception i get running it

  @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 {}

And here is the exception i get:

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

would you help me please?

you should specify the media types first

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM