Allow encoding to be set with a Charset in FreeMarker support
Closes gh-33102
This commit is contained in:
@@ -18,6 +18,7 @@ package org.springframework.ui.freemarker;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
@@ -146,6 +147,7 @@ public class FreeMarkerConfigurationFactory {
|
||||
* <p>Note that the encoding is not used for template rendering. Instead, an
|
||||
* explicit encoding must be specified for the rendering process — for
|
||||
* example, via Spring's {@code FreeMarkerView} or {@code FreeMarkerViewResolver}.
|
||||
* @see #setDefaultEncoding(Charset)
|
||||
* @see freemarker.template.Configuration#setDefaultEncoding
|
||||
* @see org.springframework.web.servlet.view.freemarker.FreeMarkerView#setEncoding
|
||||
* @see org.springframework.web.servlet.view.freemarker.FreeMarkerView#setContentType
|
||||
@@ -155,6 +157,18 @@ public class FreeMarkerConfigurationFactory {
|
||||
this.defaultEncoding = defaultEncoding;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the default encoding for the FreeMarker {@link Configuration}, which
|
||||
* is used to decode byte sequences to character sequences when reading template
|
||||
* files.
|
||||
* <p>See {@link #setDefaultEncoding(String)} for details.
|
||||
* @since 6.2
|
||||
* @see java.nio.charset.StandardCharsets
|
||||
*/
|
||||
public void setDefaultEncoding(Charset defaultEncoding) {
|
||||
setDefaultEncoding(defaultEncoding.name());
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a List of {@link TemplateLoader TemplateLoaders} that will be used to
|
||||
* search for templates.
|
||||
|
||||
Reference in New Issue
Block a user