public abstract class AbstractHandlerMapping extends WebApplicationObjectSupport implements HandlerMapping, Ordered
HandlerMapping 実装の抽象基本クラス。順序付け、デフォルトハンドラー、パスパターンによってマッピングされたハンドラーインターセプタを含むハンドラーインターセプタをサポートします。 メモ: この基本クラスは、HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE の公開をサポートしていません。この属性のサポートは、通常リクエスト URL マッピングに基づいた具象サブクラスまでです。
getHandlerInternal(javax.servlet.http.HttpServletRequest), setDefaultHandler(java.lang.Object), setAlwaysUseFullPath(boolean), setUrlDecode(boolean), AntPathMatcher, setInterceptors(java.lang.Object...), HandlerInterceptorloggerBEST_MATCHING_PATTERN_ATTRIBUTE, INTROSPECT_TYPE_LEVEL_MAPPING, MATRIX_VARIABLES_ATTRIBUTE, PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE, PRODUCIBLE_MEDIA_TYPES_ATTRIBUTE, URI_TEMPLATE_VARIABLES_ATTRIBUTEHIGHEST_PRECEDENCE, LOWEST_PRECEDENCE| コンストラクターと説明 |
|---|
AbstractHandlerMapping() |
| 修飾子と型 | メソッドと説明 |
|---|---|
protected HandlerInterceptor | adaptInterceptor(ObjectSE interceptor) 指定されたインターセプターオブジェクトを HandlerInterceptor インターフェースに適合させます。 |
protected void | detectMappedInterceptors(ListSE<HandlerInterceptor> mappedInterceptors) 型 MappedInterceptor の Bean を検出し、マッピングされたインターセプターのリストに追加します。 |
protected void | extendInterceptors(ListSE<ObjectSE> interceptors) 構成されたインターセプター( setInterceptors(java.lang.Object...) を参照)を指定すると、サブクラスがオーバーライドして追加のインターセプターを登録できる拡張フック。 |
protected HandlerInterceptor[] | getAdaptedInterceptors() 適応インターセプターを HandlerInterceptor 配列として返します。 |
protected CorsConfiguration | getCorsConfiguration(ObjectSE handler, HttpServletRequestEE request) 指定されたハンドラーの CORS 構成を取得します。 |
MapSE<StringSE, CorsConfiguration> | getCorsConfigurations()CORS 構成を取得します。 |
protected HandlerExecutionChain | getCorsHandlerExecutionChain(HttpServletRequestEE request, HandlerExecutionChain chain, CorsConfiguration config)CORS 関連の処理のために HandlerExecutionChain を更新します。 |
CorsProcessor | getCorsProcessor() 設定された CorsProcessor を返します。 |
ObjectSE | getDefaultHandler() このハンドラーマッピングのデフォルトハンドラーを返します。ない場合は null を返します。 |
HandlerExecutionChain | getHandler(HttpServletRequestEE request) 特定のリクエストのハンドラーを検索し、特定のハンドラーが見つからない場合はデフォルトのハンドラーにフォールバックします。 |
protected HandlerExecutionChain | getHandlerExecutionChain(ObjectSE handler, HttpServletRequestEE request) 該当するインターセプターを含む、指定されたハンドラー用の HandlerExecutionChain を作成します。 |
protected abstract ObjectSE | getHandlerInternal(HttpServletRequestEE request) 特定のリクエストのハンドラーを検索し、特定のリクエストが見つからない場合は null を返します。 |
protected MappedInterceptor[] | getMappedInterceptors() 構成されたすべての MappedInterceptor を配列として返します。 |
int | getOrder() このオブジェクトの順序値を取得します。 |
PathMatcher | getPathMatcher() 登録された URL パターンに対して URL パスを照合するために使用する PathMatcher 実装を返します。 |
UrlPathHelper | getUrlPathHelper() ルックアップパスの解決に使用する UrlPathHelper 実装を返します。 |
protected void | initApplicationContext() インターセプターを初期化します。 |
protected void | initInterceptors() 指定されたインターセプターを初期化し、 MappedInterceptor を確認し、必要に応じて HandlerInterceptor および WebRequestInterceptor を調整します。 |
void | setAlwaysUseFullPath(boolean alwaysUseFullPath)URL 検索で常に現在のサーブレットコンテキスト内のフルパスを使用するかどうかを設定します。 |
void | setCorsConfigurations(MapSE<StringSE, CorsConfiguration> corsConfigurations)URL パターンに基づいて " グローバル " CORS 構成を設定します。 |
void | setCorsProcessor(CorsProcessor corsProcessor) 一致する CorsConfiguration をリクエストに適用するために使用するカスタム CorsProcessor を構成します。 |
void | setDefaultHandler(ObjectSE defaultHandler) このハンドラーマッピングのデフォルトハンドラーを設定します。 |
void | setInterceptors(ObjectSE... interceptors) このハンドラーマッピングによってマップされたすべてのハンドラーに適用するインターセプターを設定します。 |
void | setOrder(int order) この HandlerMapping Bean の順序値を指定します。 |
void | setPathMatcher(PathMatcher pathMatcher) 登録された URL パターンに対する URL パスのマッチングに使用する PathMatcher 実装を設定します。 |
void | setRemoveSemicolonContent(boolean removeSemicolonContent) ";" の場合に設定(セミコロン)コンテンツはリクエスト URI から削除する必要があります。 |
void | setUrlDecode(boolean urlDecode) コンテキストパスとリクエスト URI を URL デコードするかどうかを設定します。 |
void | setUrlPathHelper(UrlPathHelper urlPathHelper) ルックアップパスの解決に使用する UrlPathHelper を設定します。 |
getServletContext, getTempDir, getWebApplicationContext, initApplicationContext, initServletContext, isContextRequired, setServletContextgetApplicationContext, getMessageSourceAccessor, requiredContextClass, setApplicationContextcloneSE, equalsSE, finalizeSE, getClassSE, hashCodeSE, notifySE, notifyAllSE, toStringSE, waitSE, waitSE, waitSEpublic final void setOrder(int order)
デフォルト値は Integer.MAX_VALUE です。つまり、順序付けされていません。
Ordered.getOrder()public final int getOrder()
Ordered 値が高いほど、優先度は低くなります。結果として、最も低い値を持つオブジェクトが最高の優先度を持ちます(サーブレット load-on-startup の値に多少似ています)。
同じ順序の値は、影響を受けるオブジェクトの任意のソート位置になります。
Ordered 内の getOrder Ordered.HIGHEST_PRECEDENCE, Ordered.LOWEST_PRECEDENCEpublic void setDefaultHandler(ObjectSE defaultHandler)
デフォルトは null で、デフォルトのハンドラーがないことを示します。
public ObjectSE getDefaultHandler()
null を返します。public void setAlwaysUseFullPath(boolean alwaysUseFullPath)
デフォルトは「false」。
public void setUrlDecode(boolean urlDecode)
サーブレット仕様(ISO-8859-1)に従って、リクエストエンコーディングまたはデフォルトエンコーディングのいずれかを使用します。
public void setRemoveSemicolonContent(boolean removeSemicolonContent)
デフォルト値は true です。
public void setUrlPathHelper(UrlPathHelper urlPathHelper)
これを使用して、デフォルトの UrlPathHelper をカスタムサブクラスでオーバーライドするか、複数の HandlerMappings および MethodNameResolvers で共通の UrlPathHelper 設定を共有します。
public UrlPathHelper getUrlPathHelper()
public void setPathMatcher(PathMatcher pathMatcher)
AntPathMatcherpublic PathMatcher getPathMatcher()
public void setInterceptors(ObjectSE... interceptors)
サポートされるインターセプター型は、HandlerInterceptor、WebRequestInterceptor、MappedInterceptor です。マップされたインターセプターは、そのパスパターンに一致するリクエスト URL にのみ適用されます。マップされたインターセプター Bean も、初期化中に型ごとに検出されます。
interceptors - ハンドラーインターセプターの配列、またはない場合は null adaptInterceptor(java.lang.Object), HandlerInterceptor, WebRequestInterceptorpublic void setCorsProcessor(CorsProcessor corsProcessor)
CorsConfiguration をリクエストに適用するために使用するカスタム CorsProcessor を構成します。 デフォルトでは、DefaultCorsProcessor が使用されます。
public CorsProcessor getCorsProcessor()
CorsProcessor を返します。public void setCorsConfigurations(MapSE<StringSE,CorsConfiguration> corsConfigurations)
public MapSE<StringSE,CorsConfiguration> getCorsConfigurations()
protected void initApplicationContext()
throws BeansExceptionApplicationObjectSupport の initApplicationContext ApplicationContextException - 初期化エラーの場合 BeansException - ApplicationContext メソッドによってスローされた場合 extendInterceptors(java.util.List), initInterceptors()protected void extendInterceptors(ListSE<ObjectSE> interceptors)
setInterceptors(java.lang.Object...) を参照)を指定すると、サブクラスがオーバーライドして追加のインターセプターを登録できる拡張フック。initInterceptors() が指定されたインターセプターを HandlerInterceptor インスタンスに適応させる前に呼び出されます。
デフォルトの実装は空です。
interceptors - 構成されたインターセプターリスト(非 null)。既存のインターセプターの前後にインターセプターを追加できます protected void detectMappedInterceptors(ListSE<HandlerInterceptor> mappedInterceptors)
MappedInterceptor の Bean を検出し、マッピングされたインターセプターのリストに追加します。 これは、setInterceptors(java.lang.Object...) を介して提供されたすべての MappedInterceptor に加えて呼び出され、デフォルトで、現在のコンテキストとその祖先から型 MappedInterceptor のすべての Bean を追加します。サブクラスはこのポリシーをオーバーライドおよび調整できます。
mappedInterceptors - MappedInterceptor インスタンスを追加する空のリスト protected void initInterceptors()
MappedInterceptor を確認し、必要に応じて HandlerInterceptor および WebRequestInterceptor を調整します。protected HandlerInterceptor adaptInterceptor(ObjectSE interceptor)
HandlerInterceptor インターフェースに適合させます。 デフォルトでは、サポートされているインターセプター型は HandlerInterceptor および WebRequestInterceptor です。指定された各 WebRequestInterceptor は WebRequestHandlerInterceptorAdapter にラップされます。サブクラスでオーバーライドできます。
interceptor - 指定されたインターセプターオブジェクト HandlerInterceptor, WebRequestInterceptor, WebRequestHandlerInterceptorAdapterprotected final HandlerInterceptor[] getAdaptedInterceptors()
HandlerInterceptor 配列として返します。HandlerInterceptor の配列。ない場合は null protected final MappedInterceptor[] getMappedInterceptors()
MappedInterceptor を配列として返します。MappedInterceptor の配列。ない場合は null public final HandlerExecutionChain getHandler(HttpServletRequestEE request) throws ExceptionSE
HandlerMapping 内の getHandler request - 現在の HTTP リクエスト ExceptionSE - 内部エラーがある場合 getHandlerInternal(javax.servlet.http.HttpServletRequest)protected abstract ObjectSE getHandlerInternal(HttpServletRequestEE request) throws ExceptionSE
null を返します。このメソッドは getHandler(javax.servlet.http.HttpServletRequest) によって呼び出されます。null の戻り値は、デフォルトのハンドラー(設定されている場合)につながります。CORS プリフライトリクエストでは、このメソッドはプリフライトリクエストではなく、URL パス、"Access-Control-Request-Method" ヘッダーからの HTTP メソッド、ヘッダーに基づいて予想される実際のリクエストに対して一致を返す必要があります "Access-Control-Request-Headers" ヘッダーから、getCorsConfigurations() を介して CORS 設定を取得できるようにします。
メモ: このメソッドは、ハンドラーオブジェクトと動的に決定されたインターセプターを組み合わせて、事前に構築された HandlerExecutionChain を返すこともあります。静的に指定されたインターセプターは、そのような既存のチェーンにマージされます。
request - 現在の HTTP リクエスト null ExceptionSE - 内部エラーがある場合 protected HandlerExecutionChain getHandlerExecutionChain(ObjectSE handler, HttpServletRequestEE request)
HandlerExecutionChain を作成します。 デフォルトの実装は、指定されたハンドラー、ハンドラーマッピングの共通インターセプター、現在のリクエスト URL に一致する MappedInterceptor を使用して、標準の HandlerExecutionChain を構築します。インターセプターは、登録された順に追加されます。サブクラスは、インターセプターのリストを継承 / 再配置するためにこれをオーバーライドできます。
注意 : 渡されたハンドラーオブジェクトは、生のハンドラーまたは事前に作成された HandlerExecutionChain の場合があります。このメソッドは、新しい HandlerExecutionChain の構築または既存のチェーンの拡張のいずれかで、これら 2 つのケースを明示的に処理する必要があります。
カスタムサブクラスにインターセプターを単純に追加するには、super.getHandlerExecutionChain(handler, request) を呼び出し、返されたチェーンオブジェクトで HandlerExecutionChain.addInterceptor(org.springframework.web.servlet.HandlerInterceptor) を呼び出すことを検討してください。
handler - 解決されたハンドラーインスタンス (非 null)request - 現在の HTTP リクエスト null ではない)getAdaptedInterceptors()protected CorsConfiguration getCorsConfiguration(ObjectSE handler, HttpServletRequestEE request)
handler - チェックするハンドラー(非 null)。request - 現在のリクエスト。null の CORS 構成。protected HandlerExecutionChain getCorsHandlerExecutionChain(HttpServletRequestEE request, HandlerExecutionChain chain, CorsConfiguration config)
プリフライトリクエストの場合、デフォルトの実装は、選択されたハンドラーを、構成された setCorsProcessor(org.springframework.web.cors.CorsProcessor) を呼び出す単純な HttpRequestHandler に置き換えます。
実際のリクエストの場合、デフォルトの実装は、CORS 関連のチェックを行い、CORS ヘッダーを追加する HandlerInterceptor を挿入します。
request - 現在のリクエスト chain - ハンドラーチェーン config - 適用可能な CORS 構成 (null の可能性あり)