-
Notifications
You must be signed in to change notification settings - Fork 38.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve documentation regarding encoding in FreeMarker support #33071
Comments
Hi @Etienne522, Congratulations on opening your first GitHub issue ever! 👍
Based on my analysis, the default encoding you have configured is used to read the template file.
I am not sure how that
That's currently to be expected. If you don't specify the content type via the Though, since I do not have access to your application, I cannot explain the contents of the
If you explicitly configure the default encoding via What can be confusing is the difference between the configured (or default) Spring currently does not update the Another potential issue is that Spring does not set the As for the Javadoc in |
FreeMarkerConfigurer
and FreeMarkerViewResolver
This comment was marked as outdated.
This comment was marked as outdated.
FreeMarkerConfigurer
and FreeMarkerViewResolver
According to the official FreeMarker documentation, Spring's FreeMarkerView implementations should be configuring the output_encoding for template rendering. To address that, this commit modifies the FreeMarkerView implementations in Web MVC and WebFlux to explicitly set the output_encoding for template rendering. See https://freemarker.apache.org/docs/pgui_misc_charset.html#autoid_53 See gh-33071 Closes gh-33106
|
Hi @Etienne522 (and anyone else interested), I overhauled our FreeMarker documentation regarding encoding in d133ab6.
Please note that as of Spring Framework 6.2, that workaround will no longer be required. For details see:
And thanks to #33102, Feel free to check out the updated documentation or try out any of the new features and let us know if you run into any issues. Thanks, Sam |
Hello! I found an issue with Freemarker support.
The following configuration will use the platform encoding instead of UTF-8 like I expected :
The resulting HTML page had the line :
even though my template had no meta tag.
I had to add
to make it work.
It seems
FreeMarkerConfigurer
default encoding is ignored becauseFreeMarkerViewResolver
overrides it, even if it was left empty.The Javadoc of
FreeMarkerConfigurer#setDefaultEncoding
mentions it will be ignored if it is explicitly specified byFreeMarkerViewResolver
, but if it was not explicitly specified, it just uses the default.Either the behavior needs to be changed, or the Javadoc updated to state that
FreeMarkerViewResolver
will always override it.I am using
spring-boot-starter-freemarker
with Spring Boot 3.2.5.Thanks again for the great framework, I hope this issue report helps.
The text was updated successfully, but these errors were encountered: