public abstract class FrameworkServlet extends HttpServletBean implements ApplicationContextAware
このクラスは、次の機能を提供します。
WebApplicationContext
インスタンスを管理します。サーブレットの構成は、サーブレットの名前空間の Bean によって決定されます。 サブクラスは、リクエストを処理するために doService(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
を実装する必要があります。これは HttpServlet を直接拡張するのではなく HttpServletBean
を継承するため、Bean プロパティが自動的にそれにマップされます。サブクラスは、カスタム初期化のために initFrameworkServlet()
をオーバーライドできます。
サーブレットの init-param レベルで "contextClass" パラメーターを検出し、見つからない場合はデフォルトのコンテキストクラス XmlWebApplicationContext
にフォールバックします。デフォルトの FrameworkServlet
では、カスタムコンテキストクラスで ConfigurableWebApplicationContext
SPI を実装する必要があることに注意してください。
1 つ以上の ApplicationContextInitializer
クラスを指定するオプションの "contextInitializerClasses" サーブレット初期化パラメーターを受け入れます。管理対象 Web アプリケーションコンテキストはこれらの初期化子に委譲され、プロパティソースの追加やコンテキストの環境に対するプロファイルのアクティブ化など、追加のプログラム構成が可能になります。" ルート " Web アプリケーションコンテキストと同じセマンティクスを持つ "contextInitializerClasses" コンテキストパラメーターをサポートする ContextLoader
も参照してください。
"contextConfigLocation" サーブレット init-param をコンテキストインスタンスに渡し、それを "test-servlet.xml, myServlet.xml" のように、任意の数のコンマとスペースで区切ることができる複数のファイルパスに解析します。明示的に指定されていない場合、コンテキスト実装はサーブレットの名前空間からデフォルトの場所を構築することになっています。
メモ: 複数の構成場所がある場合、少なくとも Spring のデフォルトの ApplicationContext 実装を使用している場合、後の Bean 定義は以前にロードされたファイルで定義された定義をオーバーライドします。これを利用して、追加の XML ファイルを介して特定の Bean 定義を意図的に上書きできます。
デフォルトの名前空間は " 'servlet-name'-servlet" です。例: サーブレット名 "test" の "test-servlet" (XmlWebApplicationContext で "/WEB-INF/test-servlet.xml" のデフォルトの場所になります)。名前空間は、「名前空間」サーブレットの init-param を介して明示的に設定することもできます。
Spring 3.1 の時点で、FrameworkServlet
は、内部で独自に作成するのではなく、Web アプリケーションコンテキストを注入できるようになりました。これは、サーブレットインスタンスのプログラムによる登録をサポートする Servlet 3.0+ 環境で役立ちます。詳細については、FrameworkServlet(WebApplicationContext)
Javadoc を参照してください。
doService(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
, setContextClass(java.lang.Class<?>)
, setContextConfigLocation(java.lang.String)
, setContextInitializerClasses(java.lang.String)
, setNamespace(java.lang.String)
, 直列化された形式 修飾子と型 | フィールドと説明 |
---|---|
static ClassSE<?> | DEFAULT_CONTEXT_CLASS FrameworkServlet のデフォルトのコンテキストクラス。 |
static StringSE | DEFAULT_NAMESPACE_SUFFIX WebApplicationContext 名前空間のサフィックス。 |
static StringSE | SERVLET_CONTEXT_PREFIX WebApplicationContext の ServletContext 属性のプレフィックス。 |
logger
コンストラクターと説明 |
---|
FrameworkServlet() サーブレットの init-params によって提供されるデフォルトと値に基づいて独自の内部 Web アプリケーションコンテキストを作成する新しい FrameworkServlet を作成します。 |
FrameworkServlet(WebApplicationContext webApplicationContext) 指定された Web アプリケーションコンテキストで新しい FrameworkServlet を作成します。 |
修飾子と型 | メソッドと説明 |
---|---|
protected void | applyInitializers(ConfigurableApplicationContext wac) WebApplicationContext がリフレッシュされる前に、"contextInitializerClasses" サーブレットの init-param で指定された ApplicationContextInitializer インスタンスに委譲します。 |
protected LocaleContext | buildLocaleContext(HttpServletRequestEE request) 指定されたリクエストの LocaleContext を構築し、リクエストのプライマリロケールを現在のロケールとして公開します。 |
protected ServletRequestAttributes | buildRequestAttributes(HttpServletRequestEE request, HttpServletResponseEE response, RequestAttributes previousAttributes) 事前バインドされた属性(およびその型)を考慮して、指定されたリクエスト(場合によってはレスポンスへの参照も保持している可能性があります)の ServletRequestAttributes をビルドします。 |
protected void | configureAndRefreshWebApplicationContext(ConfigurableWebApplicationContext wac) |
protected WebApplicationContext | createWebApplicationContext(ApplicationContext parent) このサーブレットの WebApplicationContext(デフォルトの XmlWebApplicationContext または設定されている場合は custom context class )をインスタンス化します。 |
protected WebApplicationContext | createWebApplicationContext(WebApplicationContext parent) このサーブレットの WebApplicationContext(デフォルトの XmlWebApplicationContext または設定されている場合は custom context class )をインスタンス化します。 |
void | destroy() このサーブレットの WebApplicationContext を閉じます。 |
protected void | doDelete(HttpServletRequestEE request, HttpServletResponseEE response) |
protected void | doGet(HttpServletRequestEE request, HttpServletResponseEE response) GET リクエストを processRequest/doService に委譲します。 |
protected void | doOptions(HttpServletRequestEE request, HttpServletResponseEE response) 必要に応じて、OPTIONS リクエストを processRequest(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) に委譲します。 |
protected void | doPost(HttpServletRequestEE request, HttpServletResponseEE response) |
protected void | doPut(HttpServletRequestEE request, HttpServletResponseEE response) |
protected abstract void | doService(HttpServletRequestEE request, HttpServletResponseEE response) サブクラスは、GET、POST、PUT、DELETE の集中コールバックを受信して、リクエスト処理の作業を行うためにこのメソッドを実装する必要があります。 |
protected void | doTrace(HttpServletRequestEE request, HttpServletResponseEE response) 必要に応じて、TRACE リクエストを processRequest(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) に委譲します。 |
protected WebApplicationContext | findWebApplicationContext() |
StringSE | getContextAttribute() このサーブレットが使用することになっている WebApplicationContext を取得するために使用する必要がある ServletContext 属性の名前を返します。 |
ClassSE<?> | getContextClass() カスタムコンテキストクラスを返します。 |
StringSE | getContextConfigLocation() 明示的なコンテキスト構成の場所があれば、それを返します。 |
StringSE | getContextId() カスタム WebApplicationContext ID を返します(ある場合)。 |
StringSE | getNamespace() このサーブレットの名前空間を返します。カスタム名前空間が設定されていない場合はデフォルトのスキームにフォールバックします。 |
StringSE | getServletContextAttributeName() このサーブレットの WebApplicationContext の ServletContext 属性名を返します。 |
protected StringSE | getUsernameForRequest(HttpServletRequestEE request) 指定されたリクエストのユーザー名を特定します。 |
WebApplicationContext | getWebApplicationContext() このサーブレットの WebApplicationContext を返します。 |
protected void | initFrameworkServlet() このメソッドは、Bean プロパティが設定され、WebApplicationContext がロードされた後に呼び出されます。 |
protected void | initServletBean() HttpServletBean のオーバーライドされたメソッド。Bean プロパティが設定された後に呼び出されます。 |
protected WebApplicationContext | initWebApplicationContext() このサーブレットの WebApplicationContext を初期化して公開します。 |
boolean | isEnableLoggingRequestDetails() 機密性が高い可能性のあるロギングの場合、DEBUG および TRACE レベルでのリクエストの詳細が許可されます。 |
void | onApplicationEvent(ContextRefreshedEvent event) このサーブレットの WebApplicationContext からリフレッシュイベントを受け取るコールバック。 |
protected void | onRefresh(ApplicationContext context) オーバーライドしてサーブレット固有のリフレッシュ作業を追加できるテンプレートメソッド。 |
protected void | postProcessWebApplicationContext(ConfigurableWebApplicationContext wac) このサーブレットのコンテキストとしてリフレッシュおよびアクティブ化される前に、指定された WebApplicationContext を後処理します。 |
protected void | processRequest(HttpServletRequestEE request, HttpServletResponseEE response) このリクエストを処理し、結果に関係なくイベントを公開します。 |
void | refresh() このサーブレットのアプリケーションコンテキストと、サーブレットの依存状態をリフレッシュします。 |
protected void | service(HttpServletRequestEE request, HttpServletResponseEE response) PATCH リクエストをインターセプトするために、親クラスの実装をオーバーライドします。 |
void | setApplicationContext(ApplicationContext applicationContext) ApplicationContextAware を介して Spring によって呼び出され、現在のアプリケーションコンテキストを挿入します。 |
void | setContextAttribute(StringSE contextAttribute) このサーブレットが使用するはずの WebApplicationContext を取得するために使用する ServletContext 属性の名前を設定します。 |
void | setContextClass(ClassSE<?> contextClass) カスタムコンテキストクラスを設定します。 |
void | setContextConfigLocation(StringSE contextConfigLocation) 名前空間から構築されたデフォルトの場所に依存するのではなく、コンテキスト構成場所を明示的に設定します。 |
void | setContextId(StringSE contextId) 基になる BeanFactory の直列化 ID として使用されるカスタム WebApplicationContext ID を指定します。 |
void | setContextInitializerClasses(StringSE contextInitializerClasses) オプションの "contextInitializerClasses" サーブレット init-param ごとに、完全修飾 ApplicationContextInitializer クラス名のセットを指定します。 |
void | setContextInitializers(ApplicationContextInitializer<?>... initializers) この FrameworkServlet で使用されるアプリケーションコンテキストを初期化するために使用する ApplicationContextInitializer インスタンスを指定します。 |
void | setDispatchOptionsRequest(boolean dispatchOptionsRequest) このサーブレットが HTTP OPTIONS リクエストを doService(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) メソッドにディスパッチするかどうかを設定します。 |
void | setDispatchTraceRequest(boolean dispatchTraceRequest) このサーブレットが HTTP TRACE リクエストを doService(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) メソッドにディスパッチするかどうかを設定します。 |
void | setEnableLoggingRequestDetails(boolean enable) DEBUG レベルのリクエストパラメーターと TRACE レベルのヘッダーをログに記録するかどうか。 |
void | setNamespace(StringSE namespace) このサーブレットのカスタム名前空間を設定し、デフォルトのコンテキスト構成の場所を構築するために使用します。 |
void | setPublishContext(boolean publishContext) このサーブレットのコンテキストを ServletContext 属性として公開するかどうかを設定します。これは、Web コンテナー内のすべてのオブジェクトで使用できます。 |
void | setPublishEvents(boolean publishEvents) このサーブレットが各リクエストの最後に ServletRequestHandledEvent を公開するかどうかを設定します。 |
void | setThreadContextInheritable(boolean threadContextInheritable) LocaleContext および RequestAttributes を子スレッドの継承可能として公開するかどうかを設定します( InheritableThreadLocal SE を使用)。 |
addRequiredProperty, createEnvironment, getEnvironment, getServletName, init, initBeanWrapper, setEnvironment
doHeadEE, getLastModifiedEE, serviceEE
getInitParameterEE, getInitParameterNamesEE, getServletConfigEE, getServletContextEE, getServletInfoEE, initEE, logEE, logEE
cloneSE, equalsSE, finalizeSE, getClassSE, hashCodeSE, notifySE, notifyAllSE, toStringSE, waitSE, waitSE, waitSE
public static final StringSE DEFAULT_NAMESPACE_SUFFIX
public static final ClassSE<?> DEFAULT_CONTEXT_CLASS
public static final StringSE SERVLET_CONTEXT_PREFIX
public FrameworkServlet()
FrameworkServlet
を作成します。通常、Servlet 2.5 以前の環境で使用されます。サーブレット登録の唯一のオプションは、引数なしのコンストラクターの使用を必要とする web.xml
によるものです。setContextConfigLocation(java.lang.String)
(init-param 'contextConfigLocation') を呼び出すと、デフォルトの XmlWebApplicationContext によってロードされる XML ファイルが指定されます。
setContextClass(java.lang.Class<?>)
(init-param 'contextClass' ) を呼び出すと、デフォルトの XmlWebApplicationContext
がオーバーライドされ、AnnotationConfigWebApplicationContext
などの代替クラスを指定できるようになります。
setContextInitializerClasses(java.lang.String)
(init-param 'contextInitializerClasses' ) を呼び出すと、refresh() の前に内部アプリケーションコンテキストをさらに構成するためにどの ApplicationContextInitializer
クラスを使用する必要があるかが示されます。
public FrameworkServlet(WebApplicationContext webApplicationContext)
FrameworkServlet
を作成します。このコンストラクターは、ServletContext.addServlet(java.lang.String, java.lang.String)
EE API を介してインスタンスベースのサーブレットの登録が可能な Servlet 3.0+ 環境で役立ちます。このコンストラクターを使用すると、次のプロパティ / init-params が無視されます:
setContextClass(Class)
/'contextClass' setContextConfigLocation(String)
/'contextConfigLocation' setContextAttribute(String)
/'contextAttribute' setNamespace(String)
/' 名前空間 ' 指定された Web アプリケーションコンテキストは、まだリフレッシュされている場合とされていない場合があります。(a)ConfigurableWebApplicationContext
の実装であり、(b)まだリフレッシュされていない場合(推奨されるアプローチ)、次のようになります。
ServletContext
および ServletConfig
オブジェクトは、アプリケーションコンテキストに委譲されます。postProcessWebApplicationContext(org.springframework.web.context.ConfigurableWebApplicationContext)
が呼び出されます setContextInitializers(org.springframework.context.ApplicationContextInitializer<?>...)
プロパティを通じて指定された ApplicationContextInitializers
が適用されます。refresh()
が呼び出されますConfigurableWebApplicationContext
を実装していない場合、ユーザーが特定のニーズに応じてこれらのアクションを実行した(または実行しない)という仮定では、上記のいずれも発生しません。 使用例については、WebApplicationInitializer
を参照してください。
webApplicationContext
- 使用するコンテキスト initWebApplicationContext()
, configureAndRefreshWebApplicationContext(org.springframework.web.context.ConfigurableWebApplicationContext)
, WebApplicationInitializer
public void setContextAttribute(@Nullable StringSE contextAttribute)
WebApplicationContext
を取得するために使用する ServletContext 属性の名前を設定します。@Nullable public StringSE getContextAttribute()
WebApplicationContext
を取得するために使用する必要がある ServletContext 属性の名前を返します。public void setContextClass(ClassSE<?> contextClass)
WebApplicationContext
型である必要があります。 デフォルトの FrameworkServlet 実装を使用する場合、コンテキストクラスは ConfigurableWebApplicationContext
インターフェースも実装する必要があります。
public ClassSE<?> getContextClass()
public void setContextId(@Nullable StringSE contextId)
public void setNamespace(StringSE namespace)
public StringSE getNamespace()
public void setContextConfigLocation(@Nullable StringSE contextConfigLocation)
@Nullable public StringSE getContextConfigLocation()
public void setContextInitializers(@Nullable ApplicationContextInitializer<?>... initializers)
FrameworkServlet
で使用されるアプリケーションコンテキストを初期化するために使用する ApplicationContextInitializer
インスタンスを指定します。public void setContextInitializerClasses(StringSE contextInitializerClasses)
ApplicationContextInitializer
クラス名のセットを指定します。public void setPublishContext(boolean publishContext)
これはテスト中に特に便利ですが、他のアプリケーションオブジェクトがこの方法でコンテキストにアクセスできるようにするのが良い方法かどうかは議論の余地があります。
public void setPublishEvents(boolean publishEvents)
public void setThreadContextInheritable(boolean threadContextInheritable)
InheritableThreadLocal
SE を使用)。生成されたバックグラウンドスレッドへの副作用を回避するため、デフォルトは "false" です。これを "true" に切り替えて、リクエストの処理中に生成され、このリクエストにのみ使用される(つまり、スレッドを再利用せずに、最初のタスクの後で終了する)カスタムの子スレッドの継承を有効にします。
警告 : 新しいスレッドをオンデマンドで追加するように構成されているスレッドプール(JDK ThreadPoolExecutor
SE など)にアクセスしている場合は、子スレッドの継承を使用しないでください。これにより、そのようなプールされたスレッドに継承されたコンテキストが公開されます。
public void setDispatchOptionsRequest(boolean dispatchOptionsRequest)
doService(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
メソッドにディスパッチするかどうかを設定します。FrameworkServlet
のデフォルトは "false" で、HttpServlet
EE のデフォルトの動作を適用します(つまり、OPTIONS リクエストへのレスポンスとしてすべての標準 HTTP リクエストメソッドを列挙します)。ただし、4.3 以降、DispatcherServlet
は、OPTIONS の組み込みサポートにより、このプロパティをデフォルトで "true" に設定していることに注意してください。
他の HTTP リクエストと同様に、OPTIONS リクエストが通常のディスパッチチェーンを経由することを希望する場合は、このフラグをオンにします。これは通常、コントローラーがそれらのリクエストを受信することを意味します。それらのエンドポイントが実際に OPTIONS リクエストを処理できることを確認してください。
コントローラーが(OPTIONS レスポンスに必要な)「許可」ヘッダーを設定しなかった場合でも、HttpServlet のデフォルトの OPTIONS 処理が適用されます。
public void setDispatchTraceRequest(boolean dispatchTraceRequest)
doService(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
メソッドにディスパッチするかどうかを設定します。 デフォルトは "false" で、HttpServlet
EE のデフォルトの動作を適用します(つまり、受信したメッセージをクライアントに反映します)。
他の HTTP リクエストと同様に、TRACE リクエストが通常のディスパッチチェーンを通過するようにしたい場合は、このフラグをオンにします。これは通常、コントローラーがそれらのリクエストを受信することを意味します。それらのエンドポイントが実際に TRACE リクエストを処理できることを確認してください。
HttpServlet のデフォルトの TRACE 処理は、コントローラーがコンテンツ型 'message/http'(TRACE レスポンスに必要な)のレスポンスを生成しない場合に適用されます。
public void setEnableLoggingRequestDetails(boolean enable)
デフォルトでは、リクエストの詳細が表示されないように false
に設定されます。
enable
- 有効にするかどうか public boolean isEnableLoggingRequestDetails()
public void setApplicationContext(ApplicationContext applicationContext)
ApplicationContextAware
を介して Spring によって呼び出されます。この方法により、FrameworkServlets を bootstrapped
コンテキストではなく、finding
ではなく既存の WebApplicationContext
内の Spring Bean として登録できます。主に埋め込まれたサーブレットコンテナーでの使用をサポートするために追加されました。
ApplicationContextAware
の setApplicationContext
applicationContext
- このオブジェクトによって使用される ApplicationContext オブジェクト BeanInitializationException
protected final void initServletBean() throws ServletExceptionEE
HttpServletBean
のオーバーライドされたメソッド。Bean プロパティが設定された後に呼び出されます。このサーブレットの WebApplicationContext を作成します。HttpServletBean
の initServletBean
ServletExceptionEE
- サブクラスの初期化が失敗した場合 protected WebApplicationContext initWebApplicationContext()
コンテキストを実際に作成するための createWebApplicationContext(org.springframework.context.ApplicationContext)
へのデリゲート。サブクラスでオーバーライドできます。
FrameworkServlet(WebApplicationContext)
, setContextClass(java.lang.Class<?>)
, setContextConfigLocation(java.lang.String)
@Nullable protected WebApplicationContext findWebApplicationContext()
configured name
を使用して、ServletContext
属性から WebApplicationContext
を取得します。このサーブレットが初期化(または起動)される前に、WebApplicationContext
がすでにロードされ、ServletContext
に格納されている必要があります。 サブクラスはこのメソッドをオーバーライドして、別の WebApplicationContext
取得戦略を提供できます。
null
getContextAttribute()
protected WebApplicationContext createWebApplicationContext(@Nullable ApplicationContext parent)
XmlWebApplicationContext
または設定されている場合は custom context class
)をインスタンス化します。 この実装は、カスタムコンテキストが ConfigurableWebApplicationContext
インターフェースを実装することを期待しています。サブクラスでオーバーライドできます。
このサーブレットインスタンスを、作成されたコンテキストのアプリケーションリスナーとして(その callback
をトリガーするために)登録し、コンテキストインスタンスを返す前に ConfigurableApplicationContext.refresh()
を呼び出すことを忘れないでください。
parent
- 使用する親 ApplicationContext、ない場合は null
XmlWebApplicationContext
protected void configureAndRefreshWebApplicationContext(ConfigurableWebApplicationContext wac)
protected WebApplicationContext createWebApplicationContext(@Nullable WebApplicationContext parent)
XmlWebApplicationContext
または custom context class
(設定されている場合))。#createWebApplicationContext(ApplicationContext)にデリゲートします。parent
- 使用する親 WebApplicationContext、ない場合は null
XmlWebApplicationContext
, createWebApplicationContext(ApplicationContext)
protected void postProcessWebApplicationContext(ConfigurableWebApplicationContext wac)
デフォルトの実装は空です。このメソッドが戻った後、refresh()
が自動的に呼び出されます。
このメソッドは、サブクラスがアプリケーションコンテキストを変更できるように設計されていますが、initWebApplicationContext()
は、エンドユーザーが ApplicationContextInitializers
を使用してコンテキストを変更できるように設計されていることに注意してください。
wac
- 設定された WebApplicationContext (まだリフレッシュされていません)createWebApplicationContext(org.springframework.context.ApplicationContext)
, initWebApplicationContext()
, ConfigurableApplicationContext.refresh()
protected void applyInitializers(ConfigurableApplicationContext wac)
ApplicationContextInitializer
インスタンスに委譲します。postProcessWebApplicationContext(org.springframework.web.context.ConfigurableWebApplicationContext)
も参照してください。これは(エンドユーザーではなく)サブクラスがアプリケーションコンテキストを変更できるように設計されており、このメソッドの直前に呼び出されます。
wac
- 設定された WebApplicationContext (まだリフレッシュされていません)createWebApplicationContext(org.springframework.context.ApplicationContext)
, postProcessWebApplicationContext(org.springframework.web.context.ConfigurableWebApplicationContext)
, ConfigurableApplicationContext.refresh()
public StringSE getServletContextAttributeName()
デフォルトの実装は SERVLET_CONTEXT_PREFIX + servlet name
を返します。
@Nullable public final WebApplicationContext getWebApplicationContext()
protected void initFrameworkServlet() throws ServletExceptionEE
ServletExceptionEE
- 初期化例外の場合 public void refresh()
public void onApplicationEvent(ContextRefreshedEvent event)
デフォルトの実装は onRefresh(org.springframework.context.ApplicationContext)
を呼び出し、このサーブレットのコンテキスト依存状態のリフレッシュをトリガーします。
event
- 受信 ApplicationContext イベント protected void onRefresh(ApplicationContext context)
この実装は空です。
context
- 現在の WebApplicationContextrefresh()
public void destroy()
ServletEE
の destroyEE
GenericServletEE
の destroyEE
ConfigurableApplicationContext.close()
protected void service(HttpServletRequestEE request, HttpServletResponseEE response) throws ServletExceptionEE, IOExceptionSE
HttpServletEE
の serviceEE
request
- クライアントがサーブレットから作成したリクエストを含む HttpServletRequest
EE オブジェクト response
- サーブレットがクライアントに返すレスポンスを含む HttpServletResponse
EE オブジェクト ServletExceptionEE
- HTTP リクエストを処理できない場合 IOExceptionSE
- サーブレットが HTTP リクエストを処理しているときに入力または出力エラーが発生した場合 Servlet.service(javax.servlet.ServletRequest, javax.servlet.ServletResponse)
EEprotected final void doGet(HttpServletRequestEE request, HttpServletResponseEE response) throws ServletExceptionEE, IOExceptionSE
また、コンテンツの長さだけをキャプチャーする NoBodyResponse
を使用して、HttpServlet の doHead
のデフォルト実装によっても呼び出されます。
HttpServletEE
の doGetEE
request
- クライアントがサーブレットに対して行ったリクエストを含む HttpServletRequest
EE オブジェクト response
- サーブレットがクライアントに送信するレスポンスを含む HttpServletResponse
EE オブジェクト ServletExceptionEE
- GET のリクエストを処理できなかった場合 IOExceptionSE
- サーブレットが GET リクエストを処理するときに入力または出力エラーが検出された場合 doService(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
, HttpServlet.doHead(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
EEprotected final void doPost(HttpServletRequestEE request, HttpServletResponseEE response) throws ServletExceptionEE, IOExceptionSE
processRequest(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
に委譲します。HttpServletEE
の doPostEE
request
- クライアントがサーブレットに対して行ったリクエストを含む HttpServletRequest
EE オブジェクト response
- サーブレットがクライアントに送信するレスポンスを含む HttpServletResponse
EE オブジェクト ServletExceptionEE
- POST のリクエストを処理できなかった場合 IOExceptionSE
- サーブレットがリクエストを処理するときに入力または出力エラーが検出された場合 doService(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
protected final void doPut(HttpServletRequestEE request, HttpServletResponseEE response) throws ServletExceptionEE, IOExceptionSE
processRequest(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
に委譲します。HttpServletEE
の doPutEE
request
- クライアントがサーブレットから作成したリクエストを含む HttpServletRequest
EE オブジェクト response
- サーブレットがクライアントに返すレスポンスを含む HttpServletResponse
EE オブジェクト ServletExceptionEE
- PUT のリクエストを処理できない場合 IOExceptionSE
- サーブレットが PUT リクエストを処理しているときに入力または出力エラーが発生した場合 doService(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
protected final void doDelete(HttpServletRequestEE request, HttpServletResponseEE response) throws ServletExceptionEE, IOExceptionSE
processRequest(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
に委譲します。HttpServletEE
の doDeleteEE
request
- クライアントがサーブレットから作成したリクエストを含む HttpServletRequest
EE オブジェクト response
- サーブレットがクライアントに返すレスポンスを含む HttpServletResponse
EE オブジェクト ServletExceptionEE
- DELETE のリクエストを処理できない場合 IOExceptionSE
- サーブレットが DELETE リクエストを処理しているときに入力または出力エラーが発生した場合 doService(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
protected void doOptions(HttpServletRequestEE request, HttpServletResponseEE response) throws ServletExceptionEE, IOExceptionSE
processRequest(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
に委譲します。それ以外の場合、およびディスパッチ後も "Allow" ヘッダーが設定されていない場合にも、HttpServlet の標準 OPTIONS 処理を適用します。
HttpServletEE
の doOptionsEE
request
- クライアントがサーブレットから作成したリクエストを含む HttpServletRequest
EE オブジェクト response
- サーブレットがクライアントに返すレスポンスを含む HttpServletResponse
EE オブジェクト ServletExceptionEE
- OPTIONS のリクエストを処理できない場合 IOExceptionSE
- サーブレットが OPTIONS リクエストを処理しているときに入力または出力エラーが発生した場合 doService(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
protected void doTrace(HttpServletRequestEE request, HttpServletResponseEE response) throws ServletExceptionEE, IOExceptionSE
processRequest(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
に委譲します。それ以外の場合は、HttpServlet の標準 TRACE 処理を適用します。
HttpServletEE
の doTraceEE
request
- クライアントがサーブレットから作成したリクエストを含む HttpServletRequest
EE オブジェクト response
- サーブレットがクライアントに返すレスポンスを含む HttpServletResponse
EE オブジェクト ServletExceptionEE
- TRACE のリクエストを処理できない場合 IOExceptionSE
- サーブレットが TRACE リクエストを処理している間に入力または出力エラーが発生した場合 doService(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
protected final void processRequest(HttpServletRequestEE request, HttpServletResponseEE response) throws ServletExceptionEE, IOExceptionSE
実際のイベント処理は、抽象 doService(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
テンプレートメソッドによって実行されます。
@Nullable protected LocaleContext buildLocaleContext(HttpServletRequestEE request)
request
- 現在の HTTP リクエスト null
LocaleContextHolder.setLocaleContext(org.springframework.context.i18n.LocaleContext)
@Nullable protected ServletRequestAttributes buildRequestAttributes(HttpServletRequestEE request, @Nullable HttpServletResponseEE response, @Nullable RequestAttributes previousAttributes)
request
- 現在の HTTP リクエスト response
- 現在の HTTP レスポンス previousAttributes
- 事前バインドされた RequestAttributes インスタンス(存在する場合)null
(以前にバインドされていない場合は、バインドされていないか)RequestContextHolder.setRequestAttributes(org.springframework.web.context.request.RequestAttributes)
@Nullable protected StringSE getUsernameForRequest(HttpServletRequestEE request)
デフォルトの実装では、UserPrincipal がある場合はその名前を使用します。サブクラスでオーバーライドできます。
request
- 現在の HTTP リクエスト null
(見つからない場合)HttpServletRequest.getUserPrincipal()
EEprotected abstract void doService(HttpServletRequestEE request, HttpServletResponseEE response) throws ExceptionSE
契約は、HttpServlet の一般的にオーバーライドされる doGet
または doPost
メソッドの契約と基本的に同じです。
このクラスは呼び出しをインターセプトして、例外処理とイベント発行が行われるようにします。
request
- 現在の HTTP リクエスト response
- 現在の HTTP レスポンス ExceptionSE
- あらゆる種類の処理が失敗した場合 HttpServlet.doGet(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
EE, HttpServlet.doPost(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
EE