title: Spring MVC does not save to database from html form
body: <p>Hello I have build a simple form which should save the data to database however when I submit the form the data is not saved. How would I resolve this ?</p>
  
  <p>form in jsp</p>
  
  <pre><code>&lt;form method="post"&gt;
      Product Name:&lt;br&gt;
      &lt;input type="text" id="productName" name="product name"&gt;
      &lt;br&gt;
      Last name:&lt;br&gt;
      &lt;input type="text" id="productSerial" name="serial number"&gt;
      &lt;input type="submit" value="Submit"&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>controller</p>
  
  <pre><code>@RequestMapping(value = "/saveNewContact", method = RequestMethod.POST)
      public ModelAndView saveContact(@RequestParam("productName") String productName,@RequestParam("productSerial") int productSerial) {
  
          Product product = new Product();
  
          product.setName(productName);
          product.setSerial(productSerial);
  
          ProductDao.saveNewProduct(product);
          return new ModelAndView("redirect:/");
      }
  </code></pre>
  
  <p>DAO implementation</p>
  
  <pre><code>public void saveNewProduct(Product product) {
  
      jdbcTemplate = new JdbcTemplate(dataSource);
  
      String sql = "INSERT INTO product (name, serial)"
                    + " VALUES (?, ?)";
      jdbcTemplate.update(sql, product.getName(), product.getSerial());
  
  }
  </code></pre>