bla*_*ank 7 java spring spring-mvc
使用Spring 3.1并给出了这样的东西:
class Thing {
public Thing() {}
public Thing(String someProperty) {}
}
class ThingEditor extends PropertyEditorSupport{
@Override
public void setAsText(String text) {
if (text != null) {
Thing thing = new Thing(text); // or by using a setter method
setValue(thing);
}
}
}
class SomeController {
@InitBinder
public void initBinder(WebDataBinder binder) {
binder.registerCustomEditor(Thing.class, new ThingEditor());
}
}
Run Code Online (Sandbox Code Playgroud)
我发现注册的属性编辑器没有被调用,除非我删除了带字符串的构造函数Thing- 这是对的吗?
为什么这样做并忽略已注册的编辑器?如何让它停止这样做?
| 归档时间: |
|
| 查看次数: |
859 次 |
| 最近记录: |