Thứ Tư, 16 tháng 7, 2014

Develop a web using struts2

Demo
Create a Struts-based web application named “BookSearch”. The index page should be displaying a list of available books and also providing a link to a Book Search Page. From the Book search page a user can search for a particular book either by Title or by Author of book. After executing the search operation, the search page will be redisplayed with a tabular list displaying book name, author, price, and description that matches the user input.

Đầu tiên ta tạo 1 cơ sở dữ liệu ,có tên là BookStore


B2:Tạo mới web application có sử dụng framwork struts2 và các components như sau


B3:Chèn thêm các thư viện


B4:Code class book.java

B5:code kết nối với database

B6:code lấy toàn bộ danh sách book và lấy book theo tên trong class bookModel


B7:Code trong class SearchBook


B8:Code ở các trang index.jsp,result.jsp và error.jsp





Kết quả:

Khi ta tìm theo tên microsoft cho kêt quả như dưới đây.



Nhận xét:

Ưu Điểm của việc sử dụng Struts2 là: có thể sử dụng bất kì POJO để nhận các hình thức đầu vào
+Hỗ trợ AJAX
+Hỗ trợ mẫu
+Dễ dàng tích hợp
+Dễ dàng sửa đổi các thẻ
+Nhiều tag hỗ trợ nhược điểm








Không có nhận xét nào:

Đăng nhận xét