|
|
|
@ -18,6 +18,7 @@ package org.springframework.web.servlet.view.freemarker; |
|
|
|
|
|
|
|
|
|
|
|
import java.io.FileNotFoundException; |
|
|
|
import java.io.FileNotFoundException; |
|
|
|
import java.io.IOException; |
|
|
|
import java.io.IOException; |
|
|
|
|
|
|
|
import java.nio.charset.Charset; |
|
|
|
import java.util.Locale; |
|
|
|
import java.util.Locale; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
|
|
|
|
@ -115,6 +116,7 @@ public class FreeMarkerView extends AbstractTemplateView { |
|
|
|
* process. See the note in the {@linkplain FreeMarkerView class-level |
|
|
|
* process. See the note in the {@linkplain FreeMarkerView class-level |
|
|
|
* documentation} for details. |
|
|
|
* documentation} for details. |
|
|
|
* @see freemarker.template.Configuration#setDefaultEncoding |
|
|
|
* @see freemarker.template.Configuration#setDefaultEncoding |
|
|
|
|
|
|
|
* @see #setEncoding(Charset) |
|
|
|
* @see #getEncoding() |
|
|
|
* @see #getEncoding() |
|
|
|
* @see #setContentType(String) |
|
|
|
* @see #setContentType(String) |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@ -122,6 +124,17 @@ public class FreeMarkerView extends AbstractTemplateView { |
|
|
|
this.encoding = encoding; |
|
|
|
this.encoding = encoding; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Set the encoding used to decode byte sequences to character sequences when |
|
|
|
|
|
|
|
* reading the FreeMarker template file for this view. |
|
|
|
|
|
|
|
* <p>See {@link #setEncoding(String)} for details. |
|
|
|
|
|
|
|
* @since 6.2 |
|
|
|
|
|
|
|
* @see java.nio.charset.StandardCharsets |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public void setEncoding(@Nullable Charset encoding) { |
|
|
|
|
|
|
|
setEncoding(encoding != null ? encoding.name() : null); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Get the encoding used to decode byte sequences to character sequences |
|
|
|
* Get the encoding used to decode byte sequences to character sequences |
|
|
|
* when reading the FreeMarker template file for this view, or {@code null} |
|
|
|
* when reading the FreeMarker template file for this view, or {@code null} |
|
|
|
@ -316,10 +329,10 @@ public class FreeMarkerView extends AbstractTemplateView { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Retrieve the FreeMarker {@link Template} for the given locale, to be |
|
|
|
* Retrieve the FreeMarker {@link Template} to be rendered by this view, for |
|
|
|
* rendered by this view. |
|
|
|
* the specified locale and using the {@linkplain #setEncoding(String) configured |
|
|
|
* <p>By default, the template specified by the "url" bean property |
|
|
|
* encoding} if set. |
|
|
|
* will be retrieved. |
|
|
|
* <p>By default, the template specified by the "url" bean property will be retrieved. |
|
|
|
* @param locale the current locale |
|
|
|
* @param locale the current locale |
|
|
|
* @return the FreeMarker {@code Template} to render |
|
|
|
* @return the FreeMarker {@code Template} to render |
|
|
|
* @throws IOException if the template file could not be retrieved |
|
|
|
* @throws IOException if the template file could not be retrieved |
|
|
|
@ -333,8 +346,9 @@ public class FreeMarkerView extends AbstractTemplateView { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Retrieve the FreeMarker {@link Template} for the specified name and locale, |
|
|
|
* Retrieve the FreeMarker {@link Template} to be rendered by this view, for |
|
|
|
* using the {@linkplain #setEncoding(String) configured encoding} if set. |
|
|
|
* the specified name and locale and using the {@linkplain #setEncoding(String) |
|
|
|
|
|
|
|
* configured encoding} if set. |
|
|
|
* <p>Can be called by subclasses to retrieve a specific template, |
|
|
|
* <p>Can be called by subclasses to retrieve a specific template, |
|
|
|
* for example to render multiple templates into a single view. |
|
|
|
* for example to render multiple templates into a single view. |
|
|
|
* @param name the file name of the desired template |
|
|
|
* @param name the file name of the desired template |
|
|
|
|