2
votes

I can't change the encoding to UTF-8, even if I explicitly specify it. Page in browser always created with encoding ISO-8859-1 and my language symbols show as "???". If it important - i'm use IntelliJ IDEA.

It's problem with freemarker because when I change it to jsp, pages generate with encoding UTF-8.

I tried to change encoding with:

  1. Check encoding in IDE
  2. <#ftl encoding>
  3. <#setting url_escaping_charset="UTF-8">
  4. <#setting output_encoding="UTF-8">
  5. specify produces parameter in @....Mapping annotations
  6. Specify encoding in FreeMarkerConfigurer
  7. Specify content type in FreeMarkerResolver
  8. Specify encoding in CharacterEncodingFilter
  9. Specify encoding in implementation of Filter
  10. Specify content type in FreeMarkerConfigurerFactory

But nothing of it didn't give me a solution

Result in browser

Freemarker template

Project in gitHub

1
This problem is most certainly outside the scope of FreeMarker. FreeMarker just writes its output to a java.io.Writer, and that's always UTF-16. It's the embedding framework/application that provides that Writer. As it will be a HTTP response in your case, at some later point the Servlet implementation will do the encoding, certainly to the charset set as the encoding of the HttpServletResponse. FreeMarker doesn't set that, as it's not dependent on Servlets. So it's a generic Servlet and/or Spring Web setting, not a FreeMarker one. - ddekany

1 Answers

0
votes

I found solution - when we implement WebMvcConfigurer and use registry.freemarker Spring configure freemarker himself and us beans FreemarkerViewResolver & Configurer did not affect anything.