public class FreeMarkerView extends AbstractUrlBasedView
View
実装。 アプリケーションコンテキストでアクセス可能な FreeMarkerConfigurer
などの単一の FreeMarkerConfig
オブジェクトに依存します。または、FreeMarker 構成を設定します。setConfiguration(freemarker.template.Configuration)
を介してこのクラスに直接設定できます。
url
プロパティは、FreeMarkerConfigurer の templateLoaderPath
に対する FreeMarker テンプレートの位置です。
メモ: Spring の FreeMarker サポートには FreeMarker 2.3 以上が必要です。
logger, REQUEST_DATA_VALUE_PROCESSOR_BEAN_NAME
BINDING_CONTEXT_ATTRIBUTE
コンストラクターと説明 |
---|
FreeMarkerView() |
修飾子と型 | メソッドと説明 |
---|---|
void | afterPropertiesSet() |
protected FreeMarkerConfig | autodetectConfiguration() ApplicationContext を介して FreeMarkerConfig オブジェクトを自動検出します。 |
boolean | checkResourceExists(LocaleSE locale) このビューに使用される FreeMarker テンプレートが存在し、有効であることを確認してください。 |
protected freemarker.template.Configuration | getConfiguration() このビューで使用される FreeMarker 構成を返します。 |
protected StringSE | getEncoding() FreeMarker テンプレートのエンコーディングを返します。 |
protected freemarker.template.ObjectWrapper | getObjectWrapper() 構成された FreeMarker ObjectWrapper 、または何も指定されていない場合は default wrapper を返します。 |
protected freemarker.template.Template | getTemplate(LocaleSE locale) このビューによってレンダリングされる、指定されたロケールの FreeMarker テンプレートを取得します。 |
protected freemarker.template.SimpleHash | getTemplateModel(MapSE<StringSE, ObjectSE> model, ServerWebExchange exchange) 指定されたモデルマップの FreeMarker テンプレートモデルを作成します。 |
protected freemarker.template.Configuration | obtainConfiguration() 実際の使用のために FreeMarker 構成を取得します。 |
protected reactor.core.publisher.Mono<VoidSE> | renderInternal(MapSE<StringSE, ObjectSE> renderAttributes, MediaType contentType, ServerWebExchange exchange) ビューを実際にレンダリングするには、サブクラスでこのメソッドを実装する必要があります。 |
void | setConfiguration(freemarker.template.Configuration configuration) このビューで使用する FreeMarker 構成を設定します。 |
void | setEncoding(StringSE encoding) FreeMarker テンプレートファイルのエンコーディングを設定します。 |
getUrl, setUrl, toString
createRequestContext, formatViewName, getApplicationContext, getBeanName, getDefaultCharset, getModelAttributes, getRequestContextAttribute, getRequestDataValueProcessor, getSupportedMediaTypes, obtainApplicationContext, render, resolveAsyncAttributes, resolveAsyncAttributes, setApplicationContext, setBeanName, setDefaultCharset, setRequestContextAttribute, setSupportedMediaTypes
cloneSE, equalsSE, finalizeSE, getClassSE, hashCodeSE, notifySE, notifyAllSE, waitSE, waitSE, waitSE
isRedirectView
public void setConfiguration(@Nullable freemarker.template.Configuration configuration)
通常、このプロパティは直接設定されません。代わりに、FreeMarker 構成を取得するために使用される Spring アプリケーションコンテキストで単一の FreeMarkerConfig
が期待されます。
@Nullable protected freemarker.template.Configuration getConfiguration()
protected freemarker.template.Configuration obtainConfiguration()
null
)IllegalStateExceptionSE
- 構成オブジェクトが設定されていない場合 public void setEncoding(@Nullable StringSE encoding)
デフォルトでは、FreeMarkerConfigurer
は FreeMarker 構成のデフォルトのエンコーディングを "UTF-8" に設定します。すべてのテンプレートが共通のエンコーディングを共有している場合は、テンプレートごとではなく、FreeMarker 構成でエンコーディングを指定することをお勧めします。
public void afterPropertiesSet() throws ExceptionSE
InitializingBean
BeanFactoryAware
、ApplicationContextAware
などを満たした後、包含 BeanFactory
によって呼び出されます。このメソッドにより、Bean インスタンスは、すべての Bean プロパティが設定されたときに、その全体的な構成の検証と最終的な初期化を実行できます。
InitializingBean
の afterPropertiesSet
AbstractUrlBasedView
の afterPropertiesSet
ExceptionSE
- 構成の誤り(必須プロパティの設定の失敗など)の場合、またはその他の理由で初期化が失敗した場合 protected FreeMarkerConfig autodetectConfiguration() throws BeansException
FreeMarkerConfig
オブジェクトを自動検出します。BeansException
- 構成インスタンスが見つからなかった場合 setConfiguration(freemarker.template.Configuration)
public boolean checkResourceExists(LocaleSE locale) throws ExceptionSE
オーバーライドして動作をカスタマイズできます。たとえば、複数のテンプレートを単一のビューにレンダリングする場合などです。
AbstractUrlBasedView
の checkResourceExists
locale
- 探している希望のロケール false
、存在しないことがわかっている場合は false
ExceptionSE
- リソースは存在するが無効である場合 (たとえば解析できませんでした)protected reactor.core.publisher.Mono<VoidSE> renderInternal(MapSE<StringSE,ObjectSE> renderAttributes, @Nullable MediaType contentType, ServerWebExchange exchange)
AbstractView
AbstractView
の renderInternal
renderAttributes
- 静的な属性よりも動的な値が優先される、結合された出力マップ(非 null
)contentType
- レンダリングするために選択されたコンテンツ型。supported media types
のいずれかと一致する必要があります。exchange
- 現在の交換 @return Mono
は、レンダリングが成功した場合と成功した場合を表します protected freemarker.template.SimpleHash getTemplateModel(MapSE<StringSE,ObjectSE> model, ServerWebExchange exchange)
デフォルトの実装は SimpleHash
を構築します。
model
- レンダリングに使用するモデル exchange
- 現在の交換 SimpleHash
またはそのサブクラスとしての FreeMarker テンプレートモデル protected freemarker.template.ObjectWrapper getObjectWrapper()
ObjectWrapper
、または何も指定されていない場合は default wrapper
を返します。Configurable.getObjectWrapper()
protected freemarker.template.Template getTemplate(LocaleSE locale) throws IOExceptionSE
デフォルトでは、"url" Bean プロパティで指定されたテンプレートが取得されます。
locale
- 現在のロケール IOExceptionSE