Esempio n. 1
0
  // http://localhost:1085/Spring3HibernateOSGi/delete/41
  @RequestMapping("/delete/{contactId}")
  public @ResponseBody String deleteContact(@PathVariable("contactId") Integer contactId) {

    contactService.removeContact(contactId);

    return listContacts();
  }
Esempio n. 2
0
  // http://localhost:1085/Spring3HibernateOSGi/add
  // firstname=hrishi&lastname=kumar&email=hhh%40hhh&telephone=123424
  @RequestMapping(value = "/add", method = RequestMethod.POST)
  public @ResponseBody String addContact(
      @ModelAttribute("contact") Contact contact, BindingResult result) {

    contactService.addContact(contact);

    return listContacts();
  }
Esempio n. 3
0
  // http://localhost:1085/Spring3HibernateOSGi/index
  // and not
  // http://localhost:8080/Spring3HibernateOSGi/index
  // 1085 is what is set in the arguments
  // Spring3HibernateOSGi is what is set in service.registerServlet("/Spring3HibernateOSGi",
  // servlet, initparam, null); in Activator.java
  // if @ResponseBody is not mentioned, spring will search for a jsp file with that value present in
  // the return string
  @RequestMapping("/index")
  public @ResponseBody String listContacts() {

    List<Contact> contacts = contactService.listContact();

    Gson gson = new Gson();
    return gson.toJson(contacts);
  }