Example usage for org.springframework.web.bind.annotation RequestMethod POST

List of usage examples for org.springframework.web.bind.annotation RequestMethod POST

Introduction

In this page you can find the example usage for org.springframework.web.bind.annotation RequestMethod POST.

Prototype

RequestMethod POST

To view the source code for org.springframework.web.bind.annotation RequestMethod POST.

Click Source Link

Usage

From source file:per.mnn.controller.CartController.java

@RequestMapping(value = "/addToCart", method = RequestMethod.POST)
public ModelAndView addToCart(HttpServletRequest request, HttpServletResponse respond) {

    ShoppingCart cart = checkCart(request);
    String productId = request.getParameter("productId");
    Session sess = HibernateUtil.getSessionFactory().openSession();

    try {// w  w  w. jav  a2  s  . c  o m
        if (productId != null && !productId.isEmpty()) {
            Query query = sess.createQuery("FROM Category");
            query.list();
            query = sess.createQuery("FROM Product as p WHERE p.id = :id");
            query.setInteger("id", Integer.parseInt(productId));
            if (!query.list().isEmpty())
                cart.add((Product) query.list().get(0), 1);
        }
    } finally {
        sess.close();
    }

    return new ModelAndView("redirect:/category");
}

From source file:mum.edu.controller.AdminController.java

@RequestMapping(value = "/pendingSwitches", method = RequestMethod.POST)
public String pendingSwitches(String cmd, int pendingSwitchId) {
    if ("Approve".equals(cmd)) {
        pendingSwitchService.approve(pendingSwitchId);
    } else {//ww w .j  a va2s .c  o m
        pendingSwitchService.reject(pendingSwitchId);
    }
    return "redirect:/admin/pendingSwitches";
}

From source file:com.dbv.user.LoginController.java

@RequestMapping(value = "/login", method = RequestMethod.POST)
public String fail(@RequestParam(FormAuthenticationFilter.DEFAULT_USERNAME_PARAM) String userName,
        Model model) {/* ww w . j  a v  a 2  s  .  c  o  m*/
    model.addAttribute(FormAuthenticationFilter.DEFAULT_USERNAME_PARAM, userName);
    return "login";
}

From source file:demo.entity.repo.rest.PersonController.java

@RequestMapping(value = "/persons", method = RequestMethod.POST)
public Person create(@RequestBody Person person) {
    return personService.create(person);
}

From source file:th.co.geniustree.dental.controller.TmpProductController.java

@RequestMapping(value = "/savetmpproduct", method = RequestMethod.POST)
private void saveTmpProduct(@RequestBody TmpProduct tmpProduct) {
    System.out//from   ww  w  .j a v  a2  s  .  c  o  m
            .println("------------------------------------------------------------------------>" + tmpProduct);
    tmpProductRepo.save(tmpProduct);
}

From source file:com.studevs.controllers.SignUp.java

@RequestMapping(value = "signup", method = RequestMethod.POST)
public String doRequest2(Model model, HttpServletRequest request,
        @ModelAttribute(value = "userInformation") UserInformation userInformation,
        BindingResult bindingResult) {/*from   w  w w  .  ja  v  a2 s .  co  m*/

    try {

        if (bindingResult.hasErrors()) {

            return "index";
        } else {

            UserInformationProvider uip = (UserInformationProvider) new BeanProvider()
                    .getBean("userInformationProvider");

            if (uip.insertUserInformation(userInformation)) {

                request.getSession().setAttribute("userInformation", userInformation);
                return "home";
            } else {

                return "signup";
            }
        }
    } catch (Exception e) {

        return "index";
    }
}

From source file:com.searshc.mygarage.controllers.mock.NCDBVinNumberSearchControllerMock.java

@RequestMapping(value = "/vinnumber", method = RequestMethod.POST, produces = MediaType.APPLICATION_XML_VALUE)
@ResponseBody/*  w ww. j  a  v  a  2s .co  m*/
public ResponseEntity<String> getVehiclesByVINNumberMock(@RequestBody final String request) {
    log.info("Request with data: " + request);
    String response = "<VehiclesResponse xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\"><TrackingEnvelope><ClientTrackingID></ClientTrackingID><ServiceTrackingID>7fc122c9-cee1-46aa-8054-c12436551991</ServiceTrackingID><GeneratedBy>SearsAutomotiveRESTServices</GeneratedBy></TrackingEnvelope><VehicleCount>20</VehicleCount><Vehicles><Vehicle><ID>25433</ID><Year>2002</Year><Make>GMC TRUCK</Make><Model>SIERRA 3500 PICKUP</Model><Engine>V8-364  6.0L</Engine><VIN>1GDJC34U52E205180</VIN><LicensePlate>000001</LicensePlate><LicensePlateState>RI</LicensePlateState></Vehicle><Vehicle><ID>27117</ID><Year>2005</Year><Make>LEXUS TRUCK</Make><Model>RX 330</Model><Engine>V6-3311 3.3L DOHC</Engine><VIN>2T2HA31U25C040754</VIN><LicensePlate>000001</LicensePlate><LicensePlateState>RI</LicensePlateState></Vehicle><Vehicle><ID>90109</ID><Year>2008</Year><Make>CHEVROLET TRUCK</Make><Model>TAHOE HYBRID</Model><Engine>V8-364  6.0L</Engine><VIN>1GNFK13528R241168</VIN><LicensePlate>000001</LicensePlate><LicensePlateState>RI</LicensePlateState></Vehicle><Vehicle><ID>76494</ID><Year>2010</Year><Make>FORD-MEDIUM DUTY</Make><Model>E450 VAN</Model><Engine>V8-363  6.0L Dsl</Engine><VIN>1FDXE4FP1ADA27998</VIN><LicensePlate>000001</LicensePlate><LicensePlateState>RI</LicensePlateState></Vehicle><Vehicle><ID>25348</ID><Year>2002</Year><Make>CHEVROLET TRUCK</Make><Model>AVALANCHE 1500</Model><Engine>V8-325  5.3L</Engine><VIN>3GNEK13T32G290123</VIN><LicensePlate>000001</LicensePlate><LicensePlateState>RI</LicensePlateState></Vehicle><Vehicle><ID>87823</ID><Year>2014</Year><Make>GMC TRUCK</Make><Model>SIERRA 1500 PICKUP</Model><Engine>V8-325  5.3L</Engine><VIN>3GTU2VEC4EG430631</VIN><LicensePlate>000001</LicensePlate><LicensePlateState>RI</LicensePlateState></Vehicle><Vehicle><ID>79922</ID><Year>2011</Year><Make>BUICK</Make><Model>LACROSSE</Model><Engine>V6-3564 3.6L DOHC</Engine><VIN>1G4GA5ED0BF355556</VIN><LicensePlate>000001</LicensePlate><LicensePlateState>RI</LicensePlateState></Vehicle><Vehicle><ID>90138</ID><Year>2007</Year><Make>TOYOTA TRUCK</Make><Model>HIGHLANDER HYBRID</Model><Engine>V6-3311 3.3L DOHC</Engine><VIN>JTEGW21A770021112</VIN><LicensePlate>000001</LicensePlate><LicensePlateState>RI</LicensePlateState></Vehicle><Vehicle><ID>18502</ID><Year>1999</Year><Make>LINCOLN</Make><Model>CONTINENTAL</Model><Engine>V8-281  4.6L DOHC</Engine><VIN>1LNHM97VXXY719437</VIN><LicensePlate>000001</LicensePlate><LicensePlateState>RI</LicensePlateState></Vehicle><Vehicle><ID>0</ID><Year>2008</Year><Make>HARLEY DAVIDSON</Make><Model>FLHT ELECTRA GLIDE</Model><Engine> </Engine><VIN>1HD1FMM118Y615438</VIN><LicensePlate>000001</LicensePlate><LicensePlateState>RI</LicensePlateState></Vehicle><Vehicle><ID>0</ID><Year>2012</Year><Make>HARLEY DAVIDSON</Make><Model>FLHP ROAD KNG POLICE</Model><Engine> </Engine><VIN>1HD1FHM11CB686416</VIN><LicensePlate>000001</LicensePlate><LicensePlateState>RI</LicensePlateState></Vehicle><Vehicle><ID>91154</ID><Year>2014</Year><Make>HONDA</Make><Model>CIVIC</Model><Engine> 4-1799 1.8L SOHC</Engine><VIN>19XFB2F83EE224116</VIN><LicensePlate>000001</LicensePlate><LicensePlateState>RI</LicensePlateState></Vehicle><Vehicle><ID>31304</ID><Year>2007</Year><Make>CHEVROLET</Make><Model>IMPALA</Model><Engine>V6-213  3.5L</Engine><VIN>2G1WB58K979345379</VIN><LicensePlate>000001</LicensePlate><LicensePlateState>RI</LicensePlateState></Vehicle><Vehicle><ID>27586</ID><Year>2006</Year><Make>FORD TRUCK</Make><Model>E350 VAN</Model><Engine>V8-363  6.0L Dsl</Engine><VIN>1FDSS34PX6HA52009</VIN><LicensePlate>000001</LicensePlate><LicensePlateState>RI</LicensePlateState></Vehicle><Vehicle><ID>76494</ID><Year>2010</Year><Make>FORD-MEDIUM DUTY</Make><Model>E450 VAN</Model><Engine>V8-363  6.0L Dsl</Engine><VIN>1FDXE4FP5ADA16034</VIN><LicensePlate>000001</LicensePlate><LicensePlateState>RI</LicensePlateState></Vehicle><Vehicle><ID>82443</ID><Year>2012</Year><Make>AUDI</Make><Model>A7</Model><Engine>V6-2995 3.0L DOHC</Engine><VIN>WAUSGAFC1CN023495</VIN><LicensePlate>000001</LicensePlate><LicensePlateState>RI</LicensePlateState></Vehicle><Vehicle><ID>96095</ID><Year>2015</Year><Make>MERCEDES BENZ TRUCK</Make><Model>GLK350</Model><Engine>V6-3498 3.5L DOHC</Engine><VIN>WDCGG8JB2FG346585</VIN><LicensePlate>000001</LicensePlate><LicensePlateState>RI</LicensePlateState></Vehicle><Vehicle><ID>34089</ID><Year>2009</Year><Make>TOYOTA TRUCK</Make><Model>RAV4</Model><Engine>V6-3456 3.5L DOHC</Engine><VIN>2T3BK31V29W009399</VIN><LicensePlate>000001</LicensePlate><LicensePlateState>RI</LicensePlateState></Vehicle><Vehicle><ID>31291</ID><Year>2007</Year><Make>CADILLAC</Make><Model>DTS</Model><Engine>V8-279  4.6L DOHC</Engine><VIN>1G6KD57Y37U227226</VIN><LicensePlate>000001</LicensePlate><LicensePlateState>RI</LicensePlateState></Vehicle><Vehicle><ID>85370</ID><Year>2013</Year><Make>CHEVROLET</Make><Model>VOLT</Model><Engine> 4-1398 1.4L DOHC</Engine><VIN>1G1RA6E40DU147560</VIN><LicensePlate>000001</LicensePlate><LicensePlateState>RI</LicensePlateState></Vehicle></Vehicles></VehiclesResponse>";
    return new ResponseEntity<String>(response, null, HttpStatus.OK);
}

From source file:runtheshow.resource.webservice.SousEventService.java

@RequestMapping(value = "/add", method = RequestMethod.POST, consumes = "application/json; charset=UTF-8")
public Boolean addSousEvent(Principal user, @RequestBody SousEvenement sousEvent,
        HttpServletResponse response) {//from   ww  w  . j  a v a 2  s  . co  m
    return metier.addSousEvent(user, sousEvent);
}

From source file:org.utb.project.controllers.UsuariosController.java

@RequestMapping(path = "/usuarios/formulario/nuevo", method = RequestMethod.POST)
public String guardar(@ModelAttribute Usuario usuario) {
    usuarioDao.agregar(usuario);// w  w w .  j  av  a 2s .c o m
    return "redirect:/usuarios/listado";
}

From source file:cl.preguntame.controller.PlataformaController.java

@ResponseBody
@RequestMapping(value = "/email", method = RequestMethod.POST)
public String correo(HttpServletRequest req) {

    try {//  www .  j a va2  s.c o m
        String host = "smtp.gmail.com";

        Properties prop = System.getProperties();

        prop.put("mail.smtp.starttls.enable", "true");
        prop.put("mail.smtp.host", host);
        prop.put("mail.smtp.user", "hector.riquelme1169@gmail.com");
        prop.put("mail.smtp.password", "rriiqquueellmmee");
        prop.put("mail.smtp.port", 587);
        prop.put("mail.smtp.auth", "true");

        Session sesion = Session.getDefaultInstance(prop, null);
        MimeMessage mensaje = new MimeMessage(sesion);

        mensaje.setFrom(new InternetAddress());
        mensaje.setRecipient(Message.RecipientType.TO, new InternetAddress("hector.riquelme1169@gmail.com"));
        mensaje.setSubject("CONTACTO MIS CONCEPTOS");
        mensaje.setText(req.getParameter("mensaje_contacto"));

        Transport transport = sesion.getTransport("smtp");
        transport.connect(host, "hector.riquelme1169@gmail.com", "rriiqquueellmmee");
        transport.sendMessage(mensaje, mensaje.getAllRecipients());

        transport.close();

    } catch (Exception e) {

    }

    return req.getParameter("mensaje_contacto") + "  -  " + req.getParameter("email_contacto");
}