Java Review of incremental deletions (CRUD)

Source: Internet
Author: User

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


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.