- Spring Boot 2.0 Cookbook(Second Edition)
- Alex Antonov
- 195字
- 2021-06-24 19:24:42
Configuring custom PropertyEditors
In the previous example, we learned how to configure converters for an HTTP request and response data. There are other kinds of conversions that take place, especially in regards to dynamically converting parameters to various objects, such as Strings to Date or an Integer.
When we declare a mapping method in a controller, Spring allows us to freely define the method signature with the exact object types that we require. The way in which this is achieved is via the use of the PropertyEditor implementations. PropertyEditor is a default concept defined as part of the JDK and designed to allow the transformation of a textual value to a given type. It was initially intended to be used to build Java Swing / Abstract Window Toolkit (AWT) GUI and later proved to be a good fit for Spring's need to convert web parameters to method argument types.
Spring MVC already provides you with a lot of PropertyEditor implementations for most of the common types, such as Boolean, Currency, and Class. Let's say that we want to create a proper Isbn class object and use this in our controller instead of a plain String.
- 數據庫技術與應用教程(Access)
- Java Data Science Cookbook
- 分布式數據庫系統:大數據時代新型數據庫技術(第3版)
- 云計算與大數據應用
- 數據驅動設計:A/B測試提升用戶體驗
- AI時代的數據價值創造:從數據底座到大模型應用落地
- 圖數據實戰:用圖思維和圖技術解決復雜問題
- gnuplot Cookbook
- 編寫有效用例
- Unity 2018 By Example(Second Edition)
- 活用數據:驅動業務的數據分析實戰
- 菜鳥學SPSS數據分析
- Oracle 11g+ASP.NET數據庫系統開發案例教程
- Mastering ROS for Robotics Programming(Second Edition)
- 數據庫基礎與應用