Introduction
Web application function
○ Provide content
○ User fills in the form
○ Submit data
Spring MVC controller provided
○ Process form display
○ Support for user submitted data
- In the Spittr app, a registration form is required for new users.
- SpitterController is a new controller that currently only has one request handling method for displaying the registration form.
Program Listing 5.13 SpitterController: Displays a form to allow users to register for the application
According to the configured InternalResourceViewResolver, the JSP “/WEB-INF/views/registerForm.jsp” will be used to render the registration form.
- Although the showRegistrationForm() method is simple, it still needs to be tested.
- Because of the simplicity of the method, testing is relatively simple. Program Listing 5.14 Test the controller method of displaying the form Note
- The name of the view is registerForm, so the name of the JSP should be registerForm.jsp.
- registerForm.jsp must contain an HTML tag for the user to enter information to register the application
Program Listing 5.15 JSP that renders the registration form
In the JSP, there is a basic HTML form that contains form fields for recording the user’s first name, last name, username, and password, as well as a submit button. In this JSP,