2

I want to add encoding to the response for the mapping controller. But for some reason a compilation error. Only requires an array of values

enter image description here

How do I add encoding to the response?

mfufb
  • 79
  • 5
  • 1
    UTF-8 encoding is no longer required by Spring as the JSON should be UTF-8 by default. The [documentation](https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/http/MediaType.html#APPLICATION_JSON_UTF8) explains it. – kidney Oct 21 '20 at 10:21
  • @kidney I know. I received a requirement to register explicitly. How to do it? – mfufb Oct 21 '20 at 11:55
  • On a second thought - the `produces` is a String, there's no reason it should give a *compilation* error (I just checked and the mapping as you have it compiles just fine). I would look for other reasons a compilation error could be shown here. The IDE should tell you why it won't compile. – kidney Oct 21 '20 at 19:52
  • @kidney the problem is that this is not java, but kotlin. That's how it is in Kotlin – Ilya Y Oct 26 '20 at 08:39

1 Answers1

4
@GetMapping("/cards", produces = ["application/json;charset=UTF-8"])
Ilya Y
  • 744
  • 6
  • 24