- 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.
推薦閱讀
- 數(shù)據(jù)產(chǎn)品經(jīng)理高效學習手冊:產(chǎn)品設計、技術常識與機器學習
- Access 2016數(shù)據(jù)庫教程(微課版·第2版)
- 有趣的二進制:軟件安全與逆向分析
- Mastering Ninject for Dependency Injection
- 大數(shù)據(jù)導論
- iOS and OS X Network Programming Cookbook
- Python金融實戰(zhàn)
- Oracle數(shù)據(jù)庫管理、開發(fā)與實踐
- SQL Server 2012實施與管理實戰(zhàn)指南
- 大數(shù)據(jù)技術原理與應用:概念、存儲、處理、分析與應用
- Access數(shù)據(jù)庫開發(fā)從入門到精通
- 大數(shù)據(jù)與機器學習:實踐方法與行業(yè)案例
- 數(shù)據(jù)指標體系:構(gòu)建方法與應用實踐
- Microsoft Dynamics NAV 2015 Professional Reporting
- 數(shù)據(jù)庫基礎與應用