public class StringTrimmerEditor extends PropertyEditorSupport
Optionally allows transforming an empty string into a null value.
Needs to be explicitly registered, e.g. for command binding.
org.springframework.validation.DataBinder#registerCustomEditor| 构造器和说明 |
|---|
StringTrimmerEditor(boolean emptyAsNull)
Create a new StringTrimmerEditor.
|
StringTrimmerEditor(String charsToDelete,
boolean emptyAsNull)
Create a new StringTrimmerEditor.
|
| 限定符和类型 | 方法和说明 |
|---|---|
String |
getAsText() |
void |
setAsText(String text) |
public StringTrimmerEditor(boolean emptyAsNull)
emptyAsNull - true if an empty String is to be
transformed into nullpublic StringTrimmerEditor(String charsToDelete, boolean emptyAsNull)
charsToDelete - a set of characters to delete, in addition to
trimming an input String. Useful for deleting unwanted line breaks:
e.g. "\r\n\f" will delete all new lines and line feeds in a String.emptyAsNull - true if an empty String is to be
transformed into nullpublic void setAsText(@Nullable
String text)
setAsText 在接口中 PropertyEditorsetAsText 在类中 PropertyEditorSupportpublic String getAsText()
getAsText 在接口中 PropertyEditorgetAsText 在类中 PropertyEditorSupport