クラス AbstractJacksonView
java.lang.ObjectSE
org.springframework.context.support.ApplicationObjectSupport
org.springframework.web.context.support.WebApplicationObjectSupport
org.springframework.web.servlet.view.AbstractView
org.springframework.web.servlet.view.AbstractJacksonView
- 実装されているすべてのインターフェース:
Aware, BeanNameAware, ApplicationContextAware, ServletContextAware, View
- 既知の直属サブクラス
JacksonJsonView, JacksonXmlView
Jackson 3.x ベースおよびコンテンツ型に依存しない
AbstractView 実装の抽象基本クラス。次の特殊なモデルエントリがサポートされています。
com.fasterxml.jackson.annotation.JsonViewキーと、JSON ビューのクラス名を値として持つ JSON ビュー。tools.jackson.databind.ser.FilterProviderキーとフィルタープロバイダークラス名を値として持つフィルタープロバイダー。
- 導入:
- 7.0
- 作成者:
- Sebastien Deleuze
フィールドのサマリー
フィールドクラス AbstractView から継承されたフィールド
DEFAULT_CONTENT_TYPEクラス ApplicationObjectSupport から継承されたフィールド
loggerインターフェース View から継承されたフィールド
PATH_VARIABLES, RESPONSE_STATUS_ATTRIBUTE, SELECTED_CONTENT_TYPEコンストラクターの概要
コンストラクター修飾子コンストラクター説明protectedAbstractJacksonView(tools.jackson.databind.cfg.MapperBuilder<?, ?> builder, StringSE contentType) protectedAbstractJacksonView(tools.jackson.databind.ObjectMapper mapper, StringSE contentType) メソッドのサマリー
修飾子と型メソッド説明protected abstract ObjectSEfilterModel(MapSE<StringSE, ObjectSE> model, jakarta.servlet.http.HttpServletRequest request) 指定されたモデルから不要な属性を除外します。final tools.jackson.core.JsonEncodingこのビューのJsonEncodingを返します。protected voidprepareResponse(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) レンダリングのために指定されたレスポンスを準備します。protected voidrenderMergedOutputModel(MapSE<StringSE, ObjectSE> model, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) ビューを実際にレンダリングするには、サブクラスでこのメソッドを実装する必要があります。voidsetDisableCaching(boolean disableCaching) 生成された JSON のキャッシュを無効にします。voidsetEncoding(tools.jackson.core.JsonEncoding encoding) このビューのJsonEncodingを設定します。abstract voidsetModelKey(StringSE modelKey) このビューによってレンダリングされるモデルの属性を設定します。voidsetUpdateContentLength(boolean updateContentLength) レスポンスの "Content-Length" ヘッダーを更新するかどうか。protected voidwriteContent(OutputStreamSE stream, ObjectSE object, @Nullable MapSE<StringSE, ObjectSE> hints) 実際の JSON コンテンツをストリームに書き込みます。protected voidwritePrefix(tools.jackson.core.JsonGenerator generator, ObjectSE object) メインコンテンツの前にプレフィックスを書きます。protected voidwriteSuffix(tools.jackson.core.JsonGenerator generator, ObjectSE object) メインコンテンツの後にサフィックスを記述します。クラス AbstractView から継承されたメソッド
addStaticAttribute, createMergedOutputModel, createRequestContext, createTemporaryOutputStream, exposeModelAsRequestAttributes, formatViewName, generatesDownloadContent, getAttributesMap, getBeanName, getContentType, getRequestContextAttribute, getRequestToExpose, getStaticAttributes, isExposePathVariables, render, setAttributes, setAttributesCSV, setAttributesMap, setBeanName, setContentType, setExposeContextBeansAsAttributes, setExposedContextBeanNames, setExposePathVariables, setRequestContextAttribute, setResponseContentType, toString, writeToResponseクラス WebApplicationObjectSupport から継承されたメソッド
getServletContext, getTempDir, getWebApplicationContext, initApplicationContext, initServletContext, isContextRequired, setServletContext
フィールドの詳細
JSON_VIEW_HINT
FILTER_PROVIDER_HINT
updateContentLength
protected boolean updateContentLength
コンストラクターの詳細
AbstractJacksonView
protected AbstractJacksonView(tools.jackson.databind.cfg.MapperBuilder<?, ?> builder, StringSE contentType) AbstractJacksonView
メソッドの詳細
setEncoding
public void setEncoding(tools.jackson.core.JsonEncoding encoding) このビューのJsonEncodingを設定します。デフォルトは UTF-8 です。
getEncoding
public final tools.jackson.core.JsonEncoding getEncoding()このビューのJsonEncodingを返します。setDisableCaching
public void setDisableCaching(boolean disableCaching) 生成された JSON のキャッシュを無効にします。デフォルトは
trueで、クライアントは生成された JSON をキャッシュできません。setUpdateContentLength
public void setUpdateContentLength(boolean updateContentLength) レスポンスの "Content-Length" ヘッダーを更新するかどうか。trueに設定すると、コンテンツの長さを判別し、レスポンスの 'Content-Length' ヘッダーを設定するために、レスポンスがバッファーに入れられます。デフォルト設定は
falseです。prepareResponse
protected void prepareResponse(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) クラスからコピーされた説明:AbstractViewレンダリングのために指定されたレスポンスを準備します。デフォルトの実装では、HTTPS 経由でダウンロードコンテンツを送信するときに IE バグの回避策が適用されます。
- オーバーライド:
- クラス
AbstractViewのprepareResponse - パラメーター:
request- 現在の HTTP リクエストresponse- 現在の HTTP レスポンス
renderMergedOutputModel
protected void renderMergedOutputModel(MapSE<StringSE, ObjectSE> model, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) throws ExceptionSEクラスからコピーされた説明:AbstractViewビューを実際にレンダリングするには、サブクラスでこのメソッドを実装する必要があります。最初のステップは、リクエストの準備です。JSP の場合、これはモデルオブジェクトをリクエスト属性として設定することを意味します。2 番目のステップは、たとえば RequestDispatcher を介した JSP を含む、実際のビューのレンダリングです。
- 次で指定:
- クラス
AbstractViewのrenderMergedOutputModel - パラメーター:
model- 静的な属性よりも動的な値が優先される、結合された出力マップ(非null)request- 現在の HTTP リクエストresponse- 現在の HTTP レスポンス- 例外:
ExceptionSE- レンダリングに失敗した場合
writeContent
protected void writeContent(OutputStreamSE stream, ObjectSE object, @Nullable MapSE<StringSE, ObjectSE> hints) throws IOExceptionSE実際の JSON コンテンツをストリームに書き込みます。- パラメーター:
stream- 使用する出力ストリームobject-filterModel(Map, HttpServletRequest)から返された、レンダリングされる値hints- データを直列化する方法に関する追加情報- 例外:
IOExceptionSE- 書き込みに失敗した場合
setModelKey
このビューによってレンダリングされるモデルの属性を設定します。設定すると、他のすべてのモデル属性は無視されます。
filterModel
protected abstract ObjectSE filterModel(MapSE<StringSE, ObjectSE> model, jakarta.servlet.http.HttpServletRequest request) 指定されたモデルから不要な属性を除外します。戻り値は、別の
MapSE または単一値オブジェクトのいずれかになります。- パラメーター:
model-renderMergedOutputModel(Map, HttpServletRequest, HttpServletResponse)に渡されるモデルrequest- 現在の HTTP リクエスト- 戻り値:
- レンダリングされる値
writePrefix
protected void writePrefix(tools.jackson.core.JsonGenerator generator, ObjectSE object) throws IOExceptionSE メインコンテンツの前にプレフィックスを書きます。- パラメーター:
generator- コンテンツを書くために使用するジェネレーターobject- 出力メッセージに書き込むオブジェクト- 例外:
IOExceptionSE
writeSuffix
protected void writeSuffix(tools.jackson.core.JsonGenerator generator, ObjectSE object) throws IOExceptionSE メインコンテンツの後にサフィックスを記述します。- パラメーター:
generator- コンテンツを書くために使用するジェネレーターobject- 出力メッセージに書き込むオブジェクト- 例外:
IOExceptionSE