public class ServletWebRequest extends ServletRequestAttributes implements NativeWebRequest
HttpServletRequest
EE 用の WebRequest
アダプター。DESTRUCTION_CALLBACK_NAME_PREFIX, immutableValueTypes
requestDestructionCallbacks
REFERENCE_REQUEST, REFERENCE_SESSION, SCOPE_REQUEST, SCOPE_SESSION
コンストラクターと説明 |
---|
ServletWebRequest(HttpServletRequestEE request) 指定されたリクエストの新しい ServletWebRequest インスタンスを作成します。 |
ServletWebRequest(HttpServletRequestEE request, HttpServletResponseEE response) 指定されたリクエスト / レスポンスペアの新しい ServletWebRequest インスタンスを作成します。 |
修飾子と型 | メソッドと説明 |
---|---|
boolean | checkNotModified(long lastModifiedTimestamp) 提供された最終変更タイムスタンプ(アプリケーションによって決定)を使用して、リクエストされたリソースが変更されたかどうかを確認します。 |
boolean | checkNotModified(StringSE etag) 提供された ETag (エンティティタグ)を使用して、アプリケーションによって決定された、リクエストされたリソースが変更されたかどうかを確認します。 |
boolean | checkNotModified(StringSE etag, long lastModifiedTimestamp) 提供された ETag (エンティティタグ)およびアプリケーションによって決定された最終変更タイムスタンプを指定して、リクエストされたリソースが変更されたかどうかを確認します。 |
StringSE | getContextPath() このリクエストのコンテキストパスを返します(通常、現在の Web アプリケーションがマップされているベースパス)。 |
StringSE | getDescription(boolean includeClientInfo) 通常、リクエスト URI とセッション ID を含む、このリクエストの簡単な説明を取得します。 |
StringSE | getHeader(StringSE headerName) 指定された名前のリクエストヘッダーを返します。ない場合は null を返します。 |
IteratorSE<StringSE> | getHeaderNames() リクエストヘッダー名のイテレーターを返します。 |
StringSE[] | getHeaderValues(StringSE headerName) 指定されたヘッダー名のリクエストヘッダー値を返します。ない場合は null を返します。 |
HttpMethod | getHttpMethod() リクエストの HTTP メソッドを返します。 |
LocaleSE | getLocale() このリクエストのプライマリロケールを返します。 |
ObjectSE | getNativeRequest() 基礎となるネイティブリクエストオブジェクトを返します。 |
<T> T | getNativeRequest(ClassSE<T> requiredType) 可能であれば、基礎となるネイティブリクエストオブジェクトを返します。 |
ObjectSE | getNativeResponse() 基になるネイティブレスポンスオブジェクトがあれば、それを返します。 |
<T> T | getNativeResponse(ClassSE<T> requiredType) 可能であれば、基礎となるネイティブレスポンスオブジェクトを返します。 |
StringSE | getParameter(StringSE paramName) 指定された名前のリクエストパラメーター、または存在しない場合は null を返します。 |
MapSE<StringSE, StringSE[]> | getParameterMap() パラメーター名をマップキー、パラメーター値をマップ値として、リクエストパラメーターの不変のマップを返します。 |
IteratorSE<StringSE> | getParameterNames() リクエストパラメーター名のイテレーターを返します。 |
StringSE[] | getParameterValues(StringSE paramName) 指定されたパラメーター名のリクエストパラメーター値を返します。ない場合は null を返します。 |
StringSE | getRemoteUser() 存在する場合、このリクエストのリモートユーザーを返します。 |
PrincipalSE | getUserPrincipal() このリクエストのユーザープリンシパルがあれば、それを返します。 |
boolean | isNotModified() |
boolean | isSecure() このリクエストが安全な転送メカニズム(SSL など)を介して送信されたかどうかを返します。 |
boolean | isUserInRole(StringSE role) ユーザーがこのリクエストに対して指定されたロールを持っているかどうかを判断します。 |
StringSE | toString() |
getAttribute, getAttributeNames, getRequest, getResponse, getSession, getSessionId, getSessionMutex, isImmutableSessionAttribute, registerDestructionCallback, registerSessionDestructionCallback, removeAttribute, resolveReference, setAttribute, updateAccessedSessionAttributes
isRequestActive, registerRequestDestructionCallback, removeRequestDestructionCallback, requestCompleted
cloneSE, equalsSE, finalizeSE, getClassSE, hashCodeSE, notifySE, notifyAllSE, waitSE, waitSE, waitSE
getAttribute, getAttributeNames, getSessionId, getSessionMutex, registerDestructionCallback, removeAttribute, resolveReference, setAttribute
public ServletWebRequest(HttpServletRequestEE request)
request
- 現在の HTTP リクエスト public ServletWebRequest(HttpServletRequestEE request, @Nullable HttpServletResponseEE response)
request
- 現在の HTTP リクエスト response
- 現在の HTTP レスポンス (自動最終変更処理用)public ObjectSE getNativeRequest()
NativeWebRequest
NativeWebRequest
の getNativeRequest
HttpServletRequest
EEpublic ObjectSE getNativeResponse()
NativeWebRequest
NativeWebRequest
の getNativeResponse
HttpServletResponse
EEpublic <T> T getNativeRequest(@Nullable ClassSE<T> requiredType)
NativeWebRequest
NativeWebRequest
の getNativeRequest
requiredType
- 目的の型のリクエストオブジェクト null
HttpServletRequest
EEpublic <T> T getNativeResponse(@Nullable ClassSE<T> requiredType)
NativeWebRequest
NativeWebRequest
の getNativeResponse
requiredType
- 希望する型のレスポンスオブジェクト null
HttpServletResponse
EE@Nullable public HttpMethod getHttpMethod()
@Nullable public StringSE getHeader(StringSE headerName)
WebRequest
null
を返します。複数値ヘッダーの場合、最初のヘッダー値を取得します。
WebRequest
の getHeader
HttpServletRequest.getHeader(String)
EE@Nullable public StringSE[] getHeaderValues(StringSE headerName)
WebRequest
null
を返します。単一値のヘッダーは、単一の要素を持つ配列として公開されます。
WebRequest
の getHeaderValues
HttpServletRequest.getHeaders(String)
EEpublic IteratorSE<StringSE> getHeaderNames()
WebRequest
WebRequest
の getHeaderNames
HttpServletRequest.getHeaderNames()
EE@Nullable public StringSE getParameter(StringSE paramName)
WebRequest
null
を返します。複数値パラメーターの場合、最初のパラメーター値を取得します。
WebRequest
の getParameter
ServletRequest.getParameter(String)
EE@Nullable public StringSE[] getParameterValues(StringSE paramName)
WebRequest
null
を返します。単一値パラメーターは、単一の要素を持つ配列として公開されます。
WebRequest
の getParameterValues
ServletRequest.getParameterValues(String)
EEpublic IteratorSE<StringSE> getParameterNames()
WebRequest
WebRequest
の getParameterNames
ServletRequest.getParameterNames()
EEpublic MapSE<StringSE,StringSE[]> getParameterMap()
WebRequest
単一値パラメーターは、単一の要素を持つ配列として公開されます。
WebRequest
の getParameterMap
ServletRequest.getParameterMap()
EEpublic LocaleSE getLocale()
WebRequest
WebRequest
の getLocale
ServletRequest.getLocale()
EEpublic StringSE getContextPath()
WebRequest
WebRequest
の getContextPath
HttpServletRequest.getContextPath()
EE@Nullable public StringSE getRemoteUser()
WebRequest
WebRequest
の getRemoteUser
HttpServletRequest.getRemoteUser()
EE@Nullable public PrincipalSE getUserPrincipal()
WebRequest
WebRequest
の getUserPrincipal
HttpServletRequest.getUserPrincipal()
EEpublic boolean isUserInRole(StringSE role)
WebRequest
WebRequest
の isUserInRole
HttpServletRequest.isUserInRole(String)
EEpublic boolean isSecure()
WebRequest
WebRequest
の isSecure
ServletRequest.isSecure()
EEpublic boolean checkNotModified(long lastModifiedTimestamp)
WebRequest
これにより、"Last-Modified" レスポンスヘッダーと HTTP ステータスが透過的に設定されます(該当する場合)。
典型的な使用箇所:
public String myHandleMethod(WebRequest webRequest, Model model) { long lastModified = // application-specific calculation if (request.checkNotModified(lastModified)) { // shortcut exit - no further processing necessary return null; } // further request processing, actually building content model.addAttribute(...); return "myViewName"; }
このメソッドは、条件付きの GET/HEAD リクエストで機能しますが、条件付きの POST/PUT/DELETE リクエストでも機能します。
注意 : この #checkNotModified(long)
メソッドのいずれかを使用できます。または WebRequest.checkNotModified(String)
。HTTP 仕様で推奨されているように、強力なエンティティタグと Last-Modified 値の両方を適用する場合は、WebRequest.checkNotModified(String, long)
を使用する必要があります。
"If-Modified-Since" ヘッダーが設定されているが日付値に解析できない場合、このメソッドはヘッダーを無視し、レスポンスの最終変更タイムスタンプの設定に進みます。
WebRequest
の checkNotModified
lastModifiedTimestamp
- アプリケーションが基礎となるリソースに対して決定したミリ秒単位の最終変更タイムスタンプ public boolean checkNotModified(StringSE etag)
WebRequest
ETag
(エンティティタグ)を使用して、アプリケーションによって決定された、リクエストされたリソースが変更されたかどうかを確認します。これにより、該当する場合は "ETag" レスポンスヘッダーと HTTP ステータスが透過的に設定されます。
典型的な使用箇所:
public String myHandleMethod(WebRequest webRequest, Model model) { String eTag = // application-specific calculation if (request.checkNotModified(eTag)) { // shortcut exit - no further processing necessary return null; } // further request processing, actually building content model.addAttribute(...); return "myViewName"; }
注意 : この #checkNotModified(String)
メソッドのいずれかを使用できます。または WebRequest.checkNotModified(long)
。HTTP 仕様で推奨されているように、強力なエンティティタグと Last-Modified 値の両方を適用する場合は、WebRequest.checkNotModified(String, long)
を使用する必要があります。
WebRequest
の checkNotModified
etag
- アプリケーションが基になるリソースに対して決定したエンティティタグ。このパラメーターには、必要に応じて引用符(")が埋め込まれます。public boolean checkNotModified(@Nullable StringSE etag, long lastModifiedTimestamp)
WebRequest
ETag
(エンティティタグ)およびアプリケーションによって決定された最終変更タイムスタンプを指定して、リクエストされたリソースが変更されたかどうかを確認します。これにより、"ETag" と "Last-Modified" のレスポンスヘッダー、および該当する場合は HTTP ステータスが透過的に設定されます。
典型的な使用箇所:
public String myHandleMethod(WebRequest webRequest, Model model) { String eTag = // application-specific calculation long lastModified = // application-specific calculation if (request.checkNotModified(eTag, lastModified)) { // shortcut exit - no further processing necessary return null; } // further request processing, actually building content model.addAttribute(...); return "myViewName"; }
このメソッドは、条件付きの GET/HEAD リクエストで機能しますが、条件付きの POST/PUT/DELETE リクエストでも機能します。
注意 : HTTP 仕様では、ETag 値と Last-Modified 値の両方を設定することを推奨していますが、#checkNotModified(String)
または WebRequest.checkNotModified(long)
を使用することもできます。
WebRequest
の checkNotModified
etag
- アプリケーションが基になるリソースに対して決定したエンティティタグ。このパラメーターには、必要に応じて引用符(")が埋め込まれます。lastModifiedTimestamp
- アプリケーションが基礎となるリソースに対して決定したミリ秒単位の最終変更タイムスタンプ public boolean isNotModified()
public StringSE getDescription(boolean includeClientInfo)
WebRequest
WebRequest
の getDescription
includeClientInfo
- セッション ID やユーザー名などのクライアント固有の情報を含めるかどうか public StringSE toString()
ServletRequestAttributes
の toString