Spring MVC uses @ initbinder tag to bind form data

In spring MVC, date, double and other types are defined in beans. Without any processing, date and double cannot be bound.

The solution is to use the @ initbinder tag provided by spring MVC

In my project, the method initbinder is added to the basecontroller and annotated with the annotation @ initbinder. Spring MVC will register these editors before binding the form. Of course, if you don't mind the trouble, you can also write them separately in each controller. The remaining controllers inherit this class. Spring itself provides a large number of implementation classes, such as customdateeditor, customboolean editor, customnumbereditor and so on, which are basically enough.

Of course, we can also not use these editor classes provided by him. Let's construct some by ourselves

In basecontroller

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>