官术网_书友最值得收藏!

How it works...

Spring automatically configures a large number of default editors; but for custom types, we have to explicitly instantiate new editors for every web request. This is done in the controller in a method that is annotated with @InitBinder. This annotation is scanned and all the detected methods should have a signature of accepting WebDataBinder as an argument. Among other things, WebDataBinder provides us with an ability to register as many custom editors as we require for the controller methods to be bound properly.

It is very important to know that PropertyEditor is not thread-safe! For this reason, we have to create a new instance of our custom editors for every web request and register them with WebDataBinder.

In case a new PropertyEditor is needed, it is best to create one by extending PropertyEditorSupport and overriding the desired methods with custom implementation.

主站蜘蛛池模板: 汾阳市| 合山市| 益阳市| 舟山市| 广昌县| 万年县| 鸡西市| 洛南县| 彭州市| 兴国县| 吴江市| 正蓝旗| 邵阳县| 隆尧县| 安化县| 嘉义县| 易门县| 虹口区| 邢台市| 郯城县| 台南市| 周至县| 普陀区| 凤阳县| 通江县| 耿马| 平远县| 龙里县| 尚义县| 泰来县| 饶平县| 城步| 固始县| 宁乡县| 株洲县| 郎溪县| 察隅县| 子洲县| 叶城县| 梁河县| 大英县|