Skip to content

Instantly share code, notes, and snippets.

@fmendozaro
Last active November 4, 2019 17:40
Show Gist options
  • Save fmendozaro/e25bbad2c9e459b86b840b098b68c970 to your computer and use it in GitHub Desktop.
Save fmendozaro/e25bbad2c9e459b86b840b098b68c970 to your computer and use it in GitHub Desktop.

Bonus

We will simulate an online shop with items on sale, but first:

  • Create an HashMap<String, Boolean> called items and create at least 6 items on it, where the String is the name of the item and the Boolean indicates if it's on sale.

Read about the @RequestParam annotation in order to handle Query Strings: https://www.baeldung.com/spring-request-param and create a ShopController that handles the following URLs:

  • /shop. The controller should show all the items in a HTML list (UL) format.
  • /shop?sale=true. The controller should show items on sale in a HTML list (OL) format.
  • /shop?order=true. The controller should show all the items in a HTML list (OL) format ordered by their name. You can read about sorting Collections here: https://www.baeldung.com/java-hashmap-sort
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment