Actual combat Day12 (iii)----Display shopping cart list

Source: Internet
Author: User
Tags json
First, display shopping cart product List

Url:/cart/cart of the request

Parameters: None

Return value: Logical view

Business logic:

1. Take a list of items from the cookie.

2. Pass the list of items to the page.




Test


Second, update the number of shopping cart items Functional Analysis

1, in the page can modify the number of items

2. Recalculate subtotals and grand totals.

3, modify the need to write a cookie.

4, each modification needs to send an AJAX request to the server, modify the number of items in the cookie on the server.

The requested Url:/cart/update/num/{itemid}/{num}

Parameters: Long itemId, int num

Business logic:

1. Receive two parameters

2. Take a list of items from a cookie

3, traverse the product list to find the corresponding product

4, update the quantity of goods

5. Write the list of items to a cookie.

6, Response E3result. JSON data.

return value:

E3result. JSON data

Test:


406 error, 90% may be Jackson bag not added. Now, there's Jackson in the project.

So, this is the other 10%.

This is because we requested the 4.html, the requested HTML, to return the exact object.

Make the following two modifications:



Start Cart-web again and the total will start to change. Third, delete shopping cart items

Functional Analysis

The requested Url:/cart/delete/{itemid}

Parameters: Product ID

Return value: Displays the shopping cart list page. URLs need to do redirect jump.

Business logic:

1. Take the product ID from the URL

2. Take a list of shopping cart items from the cookie

3, traverse the list to find the corresponding product

4. Delete the product.

5. Write the list of items to a cookie.

6. Return to Logical view: Make redirect jump in logical 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.