title: How to add more shopping cart not increment quantity when refresh page in spring mvc hibernate
body: <p>I create shopping cart in spring mvc . I can add shopping cart and add continue shopping cart using function like below :</p>
  
  <pre><code>@RequestMapping(value = "/ordernow", method = RequestMethod.POST)
  public String ordernow(@ModelAttribute("product") Product product, HttpSession session) {
  
      if (session.getAttribute("cart") == null) {
          List&lt;Item&gt; cart = new ArrayList&lt;Item&gt;();
          cart.add(new Item(this.pm.find(product.getId()), 1));
          session.setAttribute("cart", cart);
      } else {
          List&lt;Item&gt; cart = (List&lt;Item&gt;) session.getAttribute("cart");
          boolean flag = false;
          for (Item item : cart) {
              if (item.getProduct().getId() == product.getId()) {
                  item.setQuantity(item.getQuantity() + 1);
                  flag = true;
                  break;
              }
          }
          if (flag == false) {
              cart.add(new Item(this.pm.find(product.getId()), 1));
          }
      }
      return "cart";
  }
  </code></pre>
  
  <p>When i refresh page quantity always increment.I don't want increment quantity when refresh page. I want increment quantity unless i click button AddToCart. 
  Please help me!</p>