Spring StringTrimmerEditor无法正常工作

de3*_*de3 2 java spring spring-mvc

我在这里读到:

http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/portlet.html#portlet-ann-webdatabinder

正如我在像其他一些问题,看到这一个,我注册在我的控制器这样的StringTrimmerEditor一个:

@Controller
public class MyController{


    @InitBinder
     public void initBinder(WebDataBinder binder) 
     {
       binder.registerCustomEditor(StringTrimmerEditor.class,new  StringTrimmerEditor(false));
     }
Run Code Online (Sandbox Code Playgroud)

它编译并运行,但不起作用,它不会修剪数据.我不知道我错过了什么.任何人?

谢谢

JB *_*zet 7

javadoc救援:

public void registerCustomEditor(Class requiredType,PropertyEditor propertyEditor)

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
Run Code Online (Sandbox Code Playgroud)

该类不应该是编辑器的类.它应该是您希望编辑器应用的字段的类型: String.class