Learn Java for Web Development

(Tina Meador) #1
CHAPTER 5: Building Java Web Applications with Spring Web MVC 251


  1. <beans:bean

  2. class="org.springframework.web.servlet.view.InternalResourceViewResolver">














   Line 12: <context:component-scan> of the dispatcher servlet registers @
Controller-annotated classes as beans. The BookListController class is
automatically discovered and registered as a bean.

Working with Forms Using Annotations

Form processing is greatly simplified with annotations-driven configuration in Spring Web MVC.
Spring removes the need for traditional form handling via the data binding mechanism that
automatically populates Java objects from the submitted form and by supporting validation and
error reports. Listing 5-46 demonstrates using a form and then processing the user-entered data.
Figure 5-21 illustrates the new files added to the bookstore directory structure.


Figure 5-21. New files in the application for form processing

Free download pdf