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:org.echocat.marquardt.example.ExampleServiceController.java

@RequestMapping(value = "/adminResource", method = RequestMethod.POST)
@ResponseStatus(HttpStatus.OK)//from   ww  w . j a v  a 2  s .  co m
public void adminResource() throws IOException {
    LOGGER.info("/exampleservice/adminResource received a request");
}

From source file:br.ufsm.csi.hotelmanagementats.controller.UsuarioAdmController.java

@RequestMapping(value = "cadastrarAdministrador.html", method = RequestMethod.POST)
public ModelAndView cadastrarUsuarioAdm(UsuarioAdministrador u, HttpServletRequest rq)
        throws NoSuchAlgorithmException, UnsupportedEncodingException {
    System.out.println("-------------------------------");
    System.out.println("Submit Formulrio de Cadastro de Administrador...");

    ModelAndView mv = new ModelAndView("/WEB-INF/views/cadastroAdministrador");

    UsuarioAdmDao uD = new UsuarioAdmDao();

    if (u.getNome() != null && u.getCpf() != null && u.getTelFixo() != null && u.getTelCel() != null
            && u.getEmail() != null && u.getSenha() != null) {

        if (u.getNome().length() > 0 && u.getCpf().length() == 14 && u.getTelCel().length() == 15
                && u.getEmail().length() > 0 && u.getSenha().length() > 0) {

            byte[] senha = rq.getParameter("senha").getBytes();

            MessageDigest md = MessageDigest.getInstance("SHA-256");
            byte[] hashSenha = md.digest(senha);

            byte[] hashSenhaBase = Base64.encodeBase64(hashSenha);
            String valorSenha = new String(hashSenhaBase, "ISO-8859-1");

            u.setSenha(valorSenha);/*from   w w  w. j  a v a 2  s  . c  om*/

            try {
                boolean retorno = uD.cadastrarUsuarioAdm(u);

                if (retorno) {
                    mv = new ModelAndView("/WEB-INF/views/paginaInicial");
                    mv.addObject("mensagem", "<Strong>Sucesso</Strong> Cadastro feito com sucesso!");
                    mv.addObject("tipo", "success");
                    System.out.println("Cadastro Concludo!");
                } else {
                    mv.addObject("mensagem", "<Strong>Erro</Strong> Dados de cadastro j utilizados!");
                    mv.addObject("tipo", "danger");
                    System.out.println("Erro ao cadastrar!");
                }

            } catch (Exception e) {
                e.printStackTrace();
                mv.addObject("mensagem", "<Strong>Erro</Strong> Dados de cadastro j utilizados!");
                mv.addObject("tipo", "danger");
                System.out.println("Erro ao cadastrar!");
            }
        }
    }

    System.out.println("\n-------------------------------\n");

    return mv;
}

From source file:com.sg.addressbookmvc.SearchController.java

@RequestMapping(value = "search/addresses", method = RequestMethod.POST)
@ResponseBody/*  w w w  .ja v a2 s  .  c  o  m*/
public List<Address> searchAddresses(@RequestBody Map<String, String> searchMap) {
    Map<SearchTerm, String> criteriaMap = new HashMap<>();

    String currentTerm = searchMap.get("residentLastName");
    if (!currentTerm.isEmpty()) {
        criteriaMap.put(SearchTerm.RESIDENTLASTNAME, currentTerm);
    }

    currentTerm = searchMap.get("streetAddress");
    if (!currentTerm.isEmpty()) {
        criteriaMap.put(SearchTerm.STREET_ADDRESS, currentTerm);
    }

    currentTerm = searchMap.get("cityName");
    if (!currentTerm.isEmpty()) {
        criteriaMap.put(SearchTerm.CITY, currentTerm);
    }

    currentTerm = searchMap.get("state");
    if (!currentTerm.isEmpty()) {
        criteriaMap.put(SearchTerm.STATE, currentTerm);
    }

    currentTerm = searchMap.get("zipCode");
    if (!currentTerm.isEmpty()) {
        criteriaMap.put(SearchTerm.ZIP, currentTerm);
    }

    return dao.searchAddresses(criteriaMap);

}

From source file:com.tsguild.videogamewebapp.controller.SearchController.java

@RequestMapping(value = "search/addresses", method = RequestMethod.POST)
@ResponseBody//  w w  w  . j a  va2  s  . c  om
public List<VideoGame> searchVideoGames(@RequestBody Map<String, String> searchMap) {
    // Create the map of search criteria to send to the DAO
    List<VideoGame> addresses = dao.getAllVideoGames();

    String title = searchMap.get("title");
    String publisher = searchMap.get("publisher");
    String genre = searchMap.get("genre");
    String multiplayer = searchMap.get("multiplayer");
    String rating = searchMap.get("rating");

    // Determine which search terms have values, translate the String
    // keys into SearchTerm enums, and set the corresponding values
    // appropriately.
    if (!title.isEmpty()) {
        addresses = (List<VideoGame>) addresses.stream().filter((VideoGame a) -> {
            String addressFirstName = a.getTitle().toLowerCase();
            String addressSearch = searchMap.get("title");
            return addressFirstName.contains(addressSearch);
        }).collect(Collectors.toList());
    }

    if (!publisher.isEmpty()) {
        addresses = addresses.stream().filter(a -> a.getPublisher().contains(publisher.toLowerCase()))
                .collect(Collectors.toList());
    }

    if (!genre.isEmpty()) {
        addresses = addresses.stream().filter(a -> a.getGenre().contains(genre.toLowerCase()))
                .collect(Collectors.toList());
    }

    if (!rating.isEmpty()) {
        addresses = addresses.stream().filter(a -> a.getEsrbRating().contains(rating.toLowerCase()))
                .collect(Collectors.toList());
    }

    return addresses;
}

From source file:com.mohit.program.controller.medicine.UpdateController.java

@RequestMapping(value = "/{id}", method = RequestMethod.POST)
public String doPost(@PathVariable("id") int id) {
    medicineDao.update(id);/*from   w ww  . j  av a 2  s . com*/
    return "redirect:/display?success";
}

From source file:org.terasoluna.gfw.functionaltest.app.transactiontoken.TransactionTokenCreateControllerWithUnderscore.java

@RequestMapping(value = "1_1", method = RequestMethod.POST)
@TransactionTokenCheck(type = TransactionTokenType.BEGIN)
public String functionTest1_1_Create() {
    return "transactiontoken/createOutputUnderscore";
}

From source file:org.busko.routemanager.web.api.RouteSubmissionApiController.java

@RequestMapping(method = RequestMethod.POST)
public String create(@Valid RouteSubmission routeSubmission, BindingResult bindingResult, Model uiModel,
        HttpServletRequest httpServletRequest) {
    if (bindingResult.hasErrors()) {
        return "dataAccessFailure";
    }//w  w  w .ja  v  a2s.  c o  m
    uiModel.asMap().clear();

    routeSubmission.setSubmittedDateTime(new Date());
    routeSubmission.uploadFileData();
    routeSubmission.persist();
    return "ok";
}

From source file:org.wallride.web.controller.admin.analytics.GoogleAnalyticsSyncController.java

@RequestMapping(method = RequestMethod.POST)
public String sync(@PathVariable String language, RedirectAttributes redirectAttributes) {
    postService.updatePostViews();// w  w  w  . ja  v a 2  s.  c o m
    return "redirect:/_admin/{language}/analytics";
}

From source file:kz.controller.RegistrationController.java

@RequestMapping(value = "/registration.htm", method = RequestMethod.POST)
public ModelAndView registration(@ModelAttribute("user") @Valid Users user, BindingResult result,
        Map<String, Object> model) throws SQLException {
    UserValidation validator = new UserValidation();
    validator.validate(user, result);//from  www.j a v a  2s  .c  om

    if (result.hasErrors()) {
        ModelAndView mv = new ModelAndView("registration");
        return mv;
    } else {
        UserDAO userService = new UserDAOImpl();
        userService.create(user);
        ModelAndView mv = new ModelAndView("success");
        mv.addObject("user", user);
        mv.addObject("success", "You registrated successfully!");
        return mv;
    }
}

From source file:com.rinxor.example.spring.mvc.controller.CreateController.java

@RequestMapping(method = RequestMethod.POST)
public @ModelAttribute("message") String create(User user) {
    return "A new user [ user = " + user.getUsername() + ", FirstName = " + user.getLastName() + ", LastName = "
            + user.getLastName() + "] has been created successfully";
}