What is the purpose of init binder in spring MVC

1) Before, you had to resort to manually parsing the date:

 public void webmethod(@RequestParam("date") String strDate) {
    Date date = ... // manually parse the date
 }

Now you can get the parsed date directly:

 public void webmethod(@RequestParam("date") Date date) {
 }

2) If your jsp page supplies a date on the form yyyy-MM-dd you can retrieve it as a Date object directly in your controller.

3) Spring tries against all registered editors to see if values can be converted into objects. You don’t have to do anything in the object itself, that’s the beauty of it.

Leave a Comment