- Spring Boot 2.0 Cookbook(Second Edition)
- Alex Antonov
- 144字
- 2021-06-24 19:24:42
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.
推薦閱讀
- 公有云容器化指南:騰訊云TKE實戰與應用
- 數據浪潮
- 數據存儲架構與技術
- Unity 5.x Game AI Programming Cookbook
- Oracle高性能自動化運維
- 數據庫程序員面試筆試真題庫
- OracleDBA實戰攻略:運維管理、診斷優化、高可用與最佳實踐
- 大數據技術入門
- 大數據治理與安全:從理論到開源實踐
- Mastering ROS for Robotics Programming(Second Edition)
- 企業大數據處理:Spark、Druid、Flume與Kafka應用實踐
- 中國云存儲發展報告
- 數字化轉型方法論:落地路徑與數據中臺
- 深入理解Flink:實時大數據處理實踐
- Tableau商業分析從新手到高手(視頻版)