| org.springframework.web.bind.WebDataBinder org.springframework.web.bind.ServletRequestDataBinder
ServletRequestDataBinder | public class ServletRequestDataBinder extends WebDataBinder (Code) | | Special DataBinder to perform data binding from servlet request parameters
to JavaBeans, including support for multipart files.
See the DataBinder/WebDataBinder superclasses for customization options,
which include specifying allowed/required fields, and registering custom
property editors.
Used by Spring web MVC's BaseCommandController and MultiActionController.
Note that BaseCommandController and its subclasses allow for easy customization
of the binder instances that they use through overriding initBinder .
Can also be used for manual data binding in custom web controllers:
for example, in a plain Controller implementation or in a MultiActionController
handler method. Simply instantiate a ServletRequestDataBinder for each binding
process, and invoke bind with the current ServletRequest as argument:
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();
...
author: Rod Johnson author: Juergen Hoeller See Also: ServletRequestDataBinder.bind(javax.servlet.ServletRequest) See Also: ServletRequestDataBinder.registerCustomEditor See Also: ServletRequestDataBinder.setAllowedFields See Also: ServletRequestDataBinder.setRequiredFields See Also: ServletRequestDataBinder.setFieldMarkerPrefix See Also: org.springframework.web.servlet.mvc.BaseCommandController.initBinder |
Method Summary | |
public void | bind(ServletRequest request) Bind the parameters of the given request to this binder's target,
also binding multipart files in case of a multipart request.
This call can create field errors, representing basic binding
errors like a required field (code "required"), or type mismatch
between value and bean property (code "typeMismatch").
Multipart files are bound via their parameter name, just like normal
HTTP parameters: i.e. | public void | closeNoCatch() Treats errors as fatal. |
ServletRequestDataBinder | public ServletRequestDataBinder(Object target, String objectName)(Code) | | Create a new ServletRequestDataBinder instance.
Parameters: target - target object to bind onto Parameters: objectName - objectName of the target object |
closeNoCatch | public void closeNoCatch() throws ServletRequestBindingException(Code) | | Treats errors as fatal. Use this method only if
it's an error if the input isn't valid.
This might be appropriate if all input is from dropdowns, for example.
throws: ServletRequestBindingException - subclass of ServletException on any binding problem |
Fields inherited from org.springframework.web.bind.WebDataBinder | final public static String DEFAULT_FIELD_MARKER_PREFIX(Code)(Java Doc)
|
|
|