Java Reference
In-Depth Information
17. <tr>
18. <td>${book.author.authorName}</td>
19.
20. <td>${book.bookTitle}</td>
21. </tr>
22. </c:forEach>
23. </table>
24. <br/>
25. <a href="addBook.html">Add books.</a>
26. </body>
27. </html>
Line 25 : The form controller is called using addBook.html , which is mapped on
lines 22 and 24 of the AddBookController in Listing 5-46.
Listing 5-49 illustrates the new JSP page of the bookstore application for form processing that will be
displayed when the AddBookController is invoked using <a href="addBook.html">Add books.</a>
on line 25 of Listing 5-48.
Listing 5-49. addBook.jsp
1. <%@page contentType="text/html" pageEncoding="UTF-8"%>
2. <%@ taglib prefix="c" uri=" http://java.sun.com/jsp/jstl/core " %>
3. <%@ taglib prefix="form" uri=" http://www.springframework.org/tags/form " %>
4.
5. <!DOCTYPE html>
6. <html>
7. <head>
8. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
9. <title>Your Book store</title>
10. </head>
11. <body>
12. <h1>Add Book</h1>
13. <form:form method="post" commandName="book">
14. Author<br />
15. <form:select path="author">
16. <form:options items="${authorList}" itemValue="authorId" itemLabel="authorName" />
17. </form:select>
18. <br /><br />
19. Book Name<br />
20. <form:input path="bookTitle"/><br /><br />
21. <br />
22. <input type="submit" value="Submit">
23. </form:form>
24. </body>
25. </html>
Listing 5-49 illustrates the form displayed. It also shows the usage of Spring form tags.
 
Search WWH ::




Custom Search