@RequestMapping("/produk/list")
 public ModelMap daftarProduk() throws Exception {
   List<Produk> hasil = produkDao.cariSemuaProduk();
   ModelMap mm = new ModelMap();
   mm.addAttribute("daftarProduk", hasil);
   return mm;
 }
 @RequestMapping("/produk/delete")
 public String hapusProduk(@RequestParam Integer id) {
   try {
     produkDao.hapus(id);
   } catch (Exception err) {
     System.out.println("Gagal hapus : " + err.getMessage());
   }
   return "redirect:list";
 }
  @RequestMapping(value = "/produk/form", method = RequestMethod.GET)
  public ModelMap tampilkanFormProduk(@RequestParam(required = false) Integer id) throws Exception {
    System.out.println("Menampilkan Form Produk");

    Produk p = produkDao.cariById(id);

    if (p == null) {
      p = new Produk();
    }

    ModelMap mm = new ModelMap();
    mm.addAttribute("produk", p);
    return mm;
  }
  @RequestMapping(value = "/produk/form", method = RequestMethod.POST)
  public String prosesFormProduk(
      @ModelAttribute @Valid Produk p, BindingResult hasilValidasi, SessionStatus status)
      throws Exception {

    p.setTerakhirUpdate(new Date());

    if (hasilValidasi.hasErrors()) {
      return "/produk/form";
    }

    produkDao.simpan(p);
    status.setComplete();
    return "redirect:list";
  }