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.