gpt4 book ai didi

java - Spring StringTrimmerEditor 不工作

转载 作者:行者123 更新时间:2023-12-01 22:40:32 25 4
gpt4 key购买 nike

正如我在这里读到的:

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

正如我在其他问题中看到的那样,如 this one ,我在我的 Controller 中注册一个 StringTrimmerEditor,如下所示:

@Controller
public class MyController{


@InitBinder
public void initBinder(WebDataBinder binder)
{
binder.registerCustomEditor(StringTrimmerEditor.class,new StringTrimmerEditor(false));
}

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

谢谢

最佳答案

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

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

关于java - Spring StringTrimmerEditor 不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8649833/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com