This complements the previous article "The meaning of layering in the Java Web." The general idea of each realization method is described.
Check for user table additions and deletions:
1:save (Save method) view (query all records) Update (Update method) Delete (Remove method) perform different actions by using this parameter
2: The Concrete realization:
(1) Save: Save page (user_save.jsp) submit data to the background of the Usersave method-> get the submitted data (GetParameter)-> encapsulate the acquired data into a user object-> need to save
(new Userdaoimpl). Save (user);
(2) View: Display list query database user table all data userlist = Udao.findall (); Request.setattribute (userlist)-> (Request Forwarding) user_view.jsp (request.getattr) (table) Mosaic display data
(3) Requirements: After the data is saved to show the list page: The Save method followed by a response.sendredirect ("Userservlet?method=view");
(4) Requirements: Add a button on the user_view.jsp page to jump to the user_save.jsp page and add the return button in user_save.jsp
(5) Update: Get the object to be modified by ID and then send the object to the modified page (in order to let the user know the previous content) to modify the page for real changes!!
Add modifications to user_view.jsp: <a href = "Userservlet?method=preupdate&id=id" > Preupdate method gets an object by ID ( object into the request scope, and then go to user_update.jsp
The current modification page is then assigned a value. Make real changes (1: Modify path 2: Don't forget to modify it by ID (hidden) update user set ... where id =?)
How to: Get an object by ID and then reset the newly modified property to update redirect to Userservlet?method=view
(6) Delete: Removes the specified record redirection by ID Userservlet?method=view