@Test
public void testCustomEditorForPrimitiveProperty() {
TestBean tb = new TestBean();
DataBinder binder = new DataBinder(tb, "tb");
binder.registerCustomEditor(int.class, "age", new PropertyEditorSupport() {
@Override
public void setAsText(String text) throws IllegalArgumentException {
setValue(new Integer(99));
}
@Override
public String getAsText() {
return "argh";
}
});
MutablePropertyValues pvs = new MutablePropertyValues();
pvs.add("age", "");
binder.bind(pvs);
assertEquals("argh", binder.getBindingResult().getFieldValue("age"));
assertEquals(99, tb.getAge());
}
DataBinderTests.java 文件源码
java
阅读 38
收藏 0
点赞 0
评论 0
项目:spring4-understanding
作者:
评论列表
文章目录