de3*_*de3 2 java spring spring-mvc
我在这里读到:
正如我在像其他一些问题,看到这一个,我注册在我的控制器这样的StringTrimmerEditor一个:
@Controller
public class MyController{
@InitBinder
public void initBinder(WebDataBinder binder)
{
binder.registerCustomEditor(StringTrimmerEditor.class,new StringTrimmerEditor(false));
}
Run Code Online (Sandbox Code Playgroud)
它编译并运行,但不起作用,它不会修剪数据.我不知道我错过了什么.任何人?
谢谢
javadoc救援:
public void registerCustomEditor(Class requiredType,PropertyEditor propertyEditor)
Run Code Online (Sandbox Code Playgroud)Description copied from interface: PropertyEditorRegistry Register the given custom property editor for all properties of the given type. Specified by: registerCustomEditor in interface PropertyEditorRegistry Parameters: requiredType - the type of the property propertyEditor - the editor to register
该类不应该是编辑器的类.它应该是您希望编辑器应用的字段的类型: String.class
归档时间: |
|
查看次数: |
1837 次 |
最近记录: |