クラス ServletRequestDataBinder
- 実装されたすべてのインターフェース:
PropertyEditorRegistry
,TypeConverter
- 既知の直属サブクラス
ExtendedServletRequestDataBinder
DataBinder
。警告 : データバインディングは、外部クライアントによるアクセスや変更を目的としていないオブジェクトグラフの部分を公開することにより、セキュリティの課題を引き起こす可能性があります。データバインディングの設計と使用は、セキュリティに関して慎重に検討する必要があります。詳細については、リファレンスマニュアルの Spring Web MVC および Spring WebFlux のデータバインディングに関する専用セクションを参照してください。
許可 / 必須フィールドの指定、カスタムプロパティエディターの登録などのカスタマイズオプションについては、DataBinder/WebDataBinder スーパークラスを参照してください。
カスタム Web コントローラーの手動データバインディングにも使用できます。たとえば、プレーンコントローラーの実装や MultiActionController ハンドラーメソッドなどです。バインディングプロセスごとに ServletRequestDataBinder をインスタンス化し、現在の ServletRequest を引数として bind
を呼び出します。
MyBean myBean = new MyBean(); // apply binder to custom target object ServletRequestDataBinder binder = new ServletRequestDataBinder(myBean); // register custom editors, if desired binder.registerCustomEditor(...); // trigger actual binding of request parameters binder.bind(request); // optionally evaluate binding errors Errors errors = binder.getErrors(); ...
- 作成者:
- Rod Johnson, Juergen Hoeller
- 関連事項:
フィールドサマリー
クラス org.springframework.web.bind.WebDataBinder から継承されたフィールド
DEFAULT_FIELD_DEFAULT_PREFIX, DEFAULT_FIELD_MARKER_PREFIX
クラス org.springframework.validation.DataBinder から継承されたフィールド
DEFAULT_AUTO_GROW_COLLECTION_LIMIT, DEFAULT_OBJECT_NAME, logger
コンストラクターのサマリー
コンストラクター説明ServletRequestDataBinder
(ObjectSE target) デフォルトのオブジェクト名で、新しい ServletRequestDataBinder インスタンスを作成します。ServletRequestDataBinder
(ObjectSE target, StringSE objectName) 新しい ServletRequestDataBinder インスタンスを作成します。メソッドのサマリー
修飾子と型メソッド説明protected void
addBindValues
(MutablePropertyValues mpvs, ServletRequestEE request) サブクラスがリクエストに追加のバインド値を追加するために使用できる拡張ポイント。void
bind
(ServletRequestEE request) 指定されたリクエストのパラメーターをこのバインダーのターゲットにバインドし、マルチパートリクエストの場合はマルチパートファイルもバインドします。void
エラーを致命的として扱います。クラス org.springframework.web.bind.WebDataBinder から継承されたメソッド
adaptEmptyArrayIndices, bindMultipart, checkFieldDefaults, checkFieldMarkers, doBind, getEmptyValue, getEmptyValue, getFieldDefaultPrefix, getFieldMarkerPrefix, isBindEmptyMultipartFiles, setBindEmptyMultipartFiles, setFieldDefaultPrefix, setFieldMarkerPrefix
クラス org.springframework.validation.DataBinder から継承されたメソッド
addCustomFormatter, addCustomFormatter, addCustomFormatter, addValidators, applyPropertyValues, bind, checkAllowedFields, checkRequiredFields, close, convertIfNecessary, convertIfNecessary, convertIfNecessary, convertIfNecessary, createBeanPropertyBindingResult, createDirectFieldBindingResult, findCustomEditor, getAllowedFields, getAutoGrowCollectionLimit, getBindingErrorProcessor, getBindingResult, getConversionService, getDisallowedFields, getInternalBindingResult, getObjectName, getPropertyAccessor, getPropertyEditorRegistry, getRequiredFields, getSimpleTypeConverter, getTarget, getTypeConverter, getValidator, getValidators, initBeanPropertyAccess, initDirectFieldAccess, isAllowed, isAutoGrowNestedPaths, isIgnoreInvalidFields, isIgnoreUnknownFields, registerCustomEditor, registerCustomEditor, replaceValidators, setAllowedFields, setAutoGrowCollectionLimit, setAutoGrowNestedPaths, setBindingErrorProcessor, setConversionService, setDisallowedFields, setIgnoreInvalidFields, setIgnoreUnknownFields, setMessageCodesResolver, setRequiredFields, setValidator, validate, validate
コンストラクターの詳細
ServletRequestDataBinder
デフォルトのオブジェクト名で、新しい ServletRequestDataBinder インスタンスを作成します。- パラメーター:
target
- バインドするターゲットオブジェクト (または、バインダーが単なるパラメーター値の変換に使用される場合はnull
)- 関連事項:
ServletRequestDataBinder
新しい ServletRequestDataBinder インスタンスを作成します。- パラメーター:
target
- バインドするターゲットオブジェクト (または、バインダーが単なるパラメーター値の変換に使用される場合はnull
)objectName
- ターゲットオブジェクトの名前
メソッドの詳細
bind
指定されたリクエストのパラメーターをこのバインダーのターゲットにバインドし、マルチパートリクエストの場合はマルチパートファイルもバインドします。この呼び出しにより、必須フィールド (コード「必須」) などの基本的なバインディングエラーや、値と Bean プロパティ (コード "typeMismatch" ) の型の不一致を表すフィールドエラーが発生する可能性があります。
マルチパートファイルは、通常の HTTP パラメーターと同様に、パラメーター名によってバインドされます。つまり、"uploadedFile" は "uploadedFile" Bean プロパティにバインドされ、"setUploadedFile" setter メソッドを呼び出します。
マルチパートファイルのターゲットプロパティの型は、MultipartFile、byte[]、または String です。サーブレットパーツバインディングは、リクエストが MultipartResolver を介して MultipartRequest に解析されていない場合にもサポートされます。
- パラメーター:
request
- バインドするパラメーターを含むリクエスト (マルチパートにすることができます)- 関連事項:
addBindValues
サブクラスがリクエストに追加のバインド値を追加するために使用できる拡張ポイント。WebDataBinder.doBind(MutablePropertyValues)
の前に呼び出されます。デフォルトの実装は空です。- パラメーター:
mpvs
- データバインディングに使用されるプロパティ値request
- 現在のリクエスト
closeNoCatch
エラーを致命的として扱います。このメソッドは、入力が有効でない場合にエラーになる場合にのみ使用してください。これは、たとえばすべての入力がドロップダウンからのものである場合に適切です。
- 例外:
ServletRequestBindingException
- バインディングの問題に関する ServletException のサブクラス