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:mx.com.quadrum.contratos.controller.crud.EstatusController.java

@ResponseBody
@RequestMapping(value = "agregarEstatus", method = RequestMethod.POST)
public String agregarEstatus(@Valid @ModelAttribute("estatus") Estatus estatus, BindingResult bindingResult,
        HttpSession session) {/*from ww  w. j a v a 2s . c om*/
    if (session.getAttribute("usuario") == null) {
        return SESION_CADUCA;
    }
    if (bindingResult.hasErrors()) {
        return ERROR_DATOS;
    }
    return estatusService.agregar(estatus);
}

From source file:edu.mum.waa.webstore.controller.UserController.java

@RequestMapping(value = { "/login" }, method = RequestMethod.POST)
public String authenticate(User user, HttpServletRequest request, RedirectAttributes redirectAttributes) {
    if (userService.authenticate(user)) {
        request.getSession().setAttribute("user", user);
        redirectAttributes.addFlashAttribute("tagline", "Welcome to the one and only amazing webstore");
        return "redirect:/welcome";
    } else {//from ww w  . ja va  2  s .co m
        throw new IllegalArgumentException("UserId and/or password invalid.");
    }
}

From source file:io.curly.artifact.integration.service.TaggerClient.java

@RequestMapping(value = "/tags", method = RequestMethod.POST)
ResponseEntity<?> postEvent(@RequestBody Set<Tag> tag);

From source file:com.swcguild.vendingmachinemvc.controller.AdminController.java

@RequestMapping(value = "/item", method = RequestMethod.POST)
@ResponseStatus(HttpStatus.CREATED)//w  w w .  j  a v a 2  s  . com
@ResponseBody
public Item createItem(@Valid @RequestBody Item item) {
    dao.addItem(item);
    return item;

}

From source file:eu.supersede.dm.rest.MethodRest.java

@RequestMapping(value = "/{methodname}/{action}", method = RequestMethod.POST)
public void postToMethod(@PathVariable String methodName, @PathVariable String action,
        @RequestParam Map<String, String> args) {
    DMMethod m = DMLibrary.get().getMethod(methodName);

    if (m != null) {
        // m.post( action, args );
    }//from   w w  w  . j a va  2s  .  c o  m
}

From source file:dicky.controlleruser.AccountController.java

@RequestMapping(value = "myaccount", method = RequestMethod.POST)
public String myaccount(HttpServletRequest request, HttpSession session, ModelMap modelMap) {
    modelMap.put("title", "My Account");
    Account account = this.accountService.login(request.getParameter("username"),
            request.getParameter("password"));
    if (account != null) {
        session.setAttribute("username", request.getParameter("username"));
        modelMap.put("fullname", account.getFullname());
        return "account.welcome";
    } else {//from  w  w  w .  j  a va  2s .c  o  m
        modelMap.put("error", "Account's Invalid!");
        return "account.myaccount";
    }

}

From source file:dijalmasilva.controllers.ControladorEvento.java

@RequestMapping(method = RequestMethod.POST)
public String save(Long id_group, Date data, HttpServletRequest req, String descricao) {
    LocalDate dataEvento = data.toLocalDate();
    Grupo grupo = grupoService.buscar(id_group);
    List<TipoResultado> resultados = retornaPossveisResultados(grupo.getIdolo().getTipo());
    Evento e = new Evento();
    e.setDataDoEvento(dataEvento);//from w  w w  . j a  va2s .  c  o m
    e.setGrupo(grupo);
    e.setDescricao(descricao);
    e.setTiposDeResultados(resultados);
    Evento eve = service.save(e);

    if (eve != null) {
        req.setAttribute("result", "Evento cadastrado com sucesso!");
    } else {
        req.setAttribute("result", "Erro ao cadastrar evento");
    }

    List<Evento> eventos = service.findByIdOfGroup(grupo.getId());
    req.setAttribute("eventos", eventos);
    req.setAttribute("group", grupo);

    return "otherGroup";
}

From source file:edu.eci.cosw.restcontrollers.ManejadorCotizaciones.java

@RequestMapping(method = RequestMethod.POST)
public ResponseEntity<?> addNewCotizacion(@RequestBody Cotizacion c) {

    return new ResponseEntity<>(HttpStatus.ACCEPTED);
}

From source file:tp.project.trafficviolationsystem.presentation.rest.OfficerRestController.java

@RequestMapping(value = "create", method = RequestMethod.POST)
@ResponseBody/* w  w  w .j  a va 2  s .  c  o  m*/
public String createOfficer(@RequestBody Officer officer) {
    officerRepository.save(officer);
    return "Officer Created";
}

From source file:com.anthony.forumspring.controller.FileUploadController.java

@RequestMapping(value = "/uploadFile", method = RequestMethod.POST)
public @ResponseBody String uploadFildHander(@RequestParam(value = "name") String name,
        @RequestParam("file") MultipartFile file) {

    if (!file.isEmpty()) {
        try {//from w ww. j  a v  a  2s.c  o m
            byte[] bytes = file.getBytes();

            // Creating the directory to store file
            String rootPath = System.getProperty("catalina.home");
            File dir = new File(rootPath + File.separator + "tmpFiles");
            if (!dir.exists()) {
                dir.mkdirs();
            }

            // Create the file on server
            File serverFile = new File(dir.getAbsolutePath() + File.separator + name);
            BufferedOutputStream stream = new BufferedOutputStream(new FileOutputStream(serverFile));
            stream.write(bytes);
            stream.close();

            //logger.info("Server File Location="
            //      + serverFile.getAbsolutePath());
            return "You successfully uploaded file=" + name;
        } catch (Exception e) {
            return "You failed to upload " + name + " => " + e.getMessage();
        }
    } else {
        return "You failed to upload " + name + " because the file was empty.";
    }
}