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:cn.aozhi.songify.web.account.LoginController.java

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

From source file:com.amazonaws.serverless.sample.spring.PetsController.java

@RequestMapping(path = "/pets", method = RequestMethod.POST)
public Pet createPet(@RequestBody Pet newPet) {
    if (newPet.getName() == null || newPet.getBreed() == null) {
        return null;
    }//from  w ww  . ja  v  a 2  s  .com

    Pet dbPet = newPet;
    dbPet.setId(UUID.randomUUID().toString());
    return dbPet;
}

From source file:com.base.controller.UserController.java

@RequestMapping(value = "/admin/user", method = RequestMethod.POST)
public String addNewUser(@ModelAttribute("user") User usr, ModelMap map) { //mappaa teacher modelattributen teach objektille
    System.out.println(usr.getUsername());
    //map.addAttribute("isLogged", true);
    try {/*w  w  w .ja  v a 2s  . c om*/
        UserDAO.addUser(usr);
        map.addAttribute("save_info", "User added succesfully!");
        map.addAttribute("users", UserDAO.getUsers());

    } catch (Exception e) {
        map.addAttribute("save_info", "Database error!");
        e.printStackTrace();
    }

    return "user";
}

From source file:com.tsg.techsupportmvc.UserController.java

@RequestMapping(value = { "/login" }, method = RequestMethod.POST)
public String logUserIn(HttpServletRequest request, RedirectAttributes redirectAttributes,
        HttpSession session) {/*from w w  w . jav  a 2 s  .  co  m*/

    Boolean userAndPasswordAreCorrect = false;
    String username = request.getParameter("username");
    String password = request.getParameter("password");

    if (dao.userExists(username)) {

        userAndPasswordAreCorrect = dao.passwordIsCorrect(username, password);

    }

    if (userAndPasswordAreCorrect) {

        userIsLoggedIn = true;

        error = "";

        User user = dao.getUserByUsername(username);

        session.setAttribute("userIsLoggedIn", userIsLoggedIn);
        session.setAttribute("user", user.getUsername());
        session.setAttribute("userRealName", user.getDisplayName());
        session.setAttribute("userSiteRole", user.getSiteRole());
        session.setAttribute("loginErrorMessage", error);
        session.setAttribute("userId", user.getUserId());

    } else {

        error = "Invalid username or password!";

    }

    return "redirect:home";

}

From source file:cs544.letmegiveexam.controller.UserController.java

@RequestMapping(value = "/addUser", method = RequestMethod.POST)
public String addStudent(@Valid User user, BindingResult result) {
    if (result.hasErrors()) {
        return "register";
    } else {//from w  w  w.  j av  a  2 s  .co m
        user.setEnabled(true);
        user.setLockCount(0);
        user.setLockTime(null);
        user.setRole_id(1);
        userServices.createUser(user);

        return "registerSuccess";
    }
}

From source file:com.eu.evaluation.web.controller.DictinaryController.java

/**
 * /*from  w  ww .  j  ava  2s .  co m*/
 */
@ResponseBody
@RequestMapping(value = "/refreshDictinary", method = RequestMethod.POST)
public void refreshDictinary() {
    dictionaryService.initDirectionary();
}

From source file:org.ucll.ip.spring_ip_project.controller.TankController.java

@RequestMapping(method = { RequestMethod.POST }, value = "/overview")
public ModelAndView getTanks(HttpServletRequest req) {
    String name = req.getParameter("player");
    req.setAttribute("player", name);
    ModelAndView view = new ModelAndView("tanks", "tanks", system.getTanksOfPlayer(name));
    view.addObject("games", system.getTotalGamesPlayed(name));
    return view;// w w w  . j av  a  2 s .c o  m
}

From source file:com.lynn.controller.LoginAction.java

@RequestMapping(value = "/login.do", method = RequestMethod.POST, produces = "text/html;charset=UTF-8")
@ResponseBody// w  w  w . j  a  va 2  s  . c om
public String loginAction(HttpServletRequest request, UserBean user) throws IOException {
    System.out.println("" + user);
    String username = user.getUsername();
    String password = user.getPassword();
    ResultBean result = null;
    if (StringUtils.isBlank(username) || StringUtils.isBlank(password)) {
        result = new ResultBean("error", "????");
        return new ObjectMapper().writeValueAsString(result);
    }
    //        UserBean tempUser = userDaoI.getByName(username);
    //        if(tempUser != null){
    //            if(!username.equalsIgnoreCase(tempUser.getUsername()) || !password.equalsIgnoreCase(tempUser.getPassword())){
    //            result = new ResultBean("error", "????!");
    //            }else{
    //                result = new ResultBean("ok", "1");
    //                request.getSession().setAttribute("user", user);
    //            }
    //        }
    return new ObjectMapper().writeValueAsString(result);
}

From source file:com.swcguild.group3capstone.controller.BlogController.java

@RequestMapping(value = "/addComment/{id}", method = RequestMethod.POST)
public void addComment(@PathVariable("id") int blogId, @RequestBody Comment comment) {

    blogDAO.addBlogComment(comment, blogId);
}

From source file:org.khmeracademy.btb.auc.pojo.controller.Topup_controller.java

@RequestMapping(value = "/add-topup-log", method = RequestMethod.POST, produces = "application/json")
public ResponseEntity<Map<String, Object>> add_topup_log(@RequestBody Topup_log topup) {
    Map<String, Object> map = new HashMap<String, Object>();
    try {/* w  w  w  . j  a  v  a  2  s.  co  m*/

        if (topup_service.add(topup)) {
            map.put("MESSAGE", "User has been inserted.");
            map.put("STATUS", true);
        } else {
            map.put("MESSAGE", "Topup log has not been inserted.");
            map.put("STATUS", false);
        }
    } catch (Exception e) {
        map.put("MESSAGE", "Error!");
        map.put("STATUS", false);
        e.printStackTrace();
    }
    return new ResponseEntity<Map<String, Object>>(map, HttpStatus.OK);
}