- 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.
推薦閱讀
- Building Computer Vision Projects with OpenCV 4 and C++
- 云計算環境下的信息資源集成與服務
- SQL Server 2008數據庫應用技術(第二版)
- 數據化網站運營深度剖析
- 大數據時代下的智能轉型進程精選(套裝共10冊)
- 數據驅動設計:A/B測試提升用戶體驗
- 數據革命:大數據價值實現方法、技術與案例
- 圖數據實戰:用圖思維和圖技術解決復雜問題
- Python數據分析與挖掘實戰(第3版)
- 數據分析師養成寶典
- Unreal Engine Virtual Reality Quick Start Guide
- 大數據與機器學習:實踐方法與行業案例
- 機器學習:實用案例解析
- 企業大數據處理:Spark、Druid、Flume與Kafka應用實踐
- 算力經濟:從超級計算到云計算