List of usage examples for org.springframework.web.bind.annotation RequestMethod POST
RequestMethod POST
To view the source code for org.springframework.web.bind.annotation RequestMethod POST.
Click Source Link
From source file:com.ajitkbaral.entitygenerator.controller.GenerateController.java
@RequestMapping(method = RequestMethod.POST) public String indexPost(HttpServletRequest request, HttpServletResponse response) { String result = ""; String packageName = request.getParameter("packageName"); String className = request.getParameter("className"); String variableNames = request.getParameter("variableNames"); String variableTypes = request.getParameter("variableTypes"); String defaultPath = request.getParameter("fullPath"); String filePath = packageName.replace(".", "\\"); String finalFilePath = defaultPath + "\\" + filePath; String finalFilePathWithEntity = finalFilePath + "\\" + className + ".java"; System.out.println("Variables and types " + variableNames + " " + variableTypes); if (!variableNames.equals("") && !variableTypes.equals("")) { List<String> variableNameList = new ArrayList<String>(); List<String> variableTypeList = new ArrayList<String>(); StringTokenizer variableNameTokenizer = new StringTokenizer(variableNames, ","); while (variableNameTokenizer.hasMoreTokens()) { variableNameList.add(variableNameTokenizer.nextToken()); }/* w w w . ja v a2 s . c om*/ StringTokenizer variableTypeTokenizer = new StringTokenizer(variableTypes, ","); while (variableTypeTokenizer.hasMoreTokens()) { variableTypeList.add(variableTypeTokenizer.nextToken()); } System.out.println(variableNameList.toString() + " " + variableTypeList.toString()); try { File fileFolder = new File(finalFilePath); if (!fileFolder.exists()) { fileFolder.mkdirs(); } FileWriter fileWriter = new FileWriter(finalFilePathWithEntity); String content = GenerateClass.packageNameContent(packageName) + GenerateClass.classNameContent(className) + GenerateClass.variableDecleration(variableNameList, variableTypeList) + GenerateClass.defaultConstructor(className) + GenerateClass.overrideConstructor(className, variableNameList, variableTypeList) + GenerateClass.getter(variableNameList, variableTypeList) + GenerateClass.setter(variableNameList, variableTypeList) + GenerateClass.close(); fileWriter.write(content); fileWriter.close(); System.out.println("DONE"); result = finalFilePathWithEntity; } catch (IOException ioe) { result = ioe.getMessage() + ". Please Try again"; } } else { result = "Error"; } return result; }
From source file:json.UserController.java
@RequestMapping(value = "/authenticateUserService", method = RequestMethod.POST, produces = "application/json") public @ResponseBody AuthenticationResponse authenticateUser(@RequestBody LoginInput loginInput) { Connection conn = null;// ww w . j a va 2 s . co m PreparedStatement stmt = null; ResultSet rs = null; String errors = null; String query = "select userPassword from user where username = ?"; /*if(loginInput.getUsername().equals("") || loginInput.getPassword().equals("")){ errors.add("Please fill in all fields."); }*/ try { //Set up connection with database conn = ConnectionManager.getConnection(); stmt = conn.prepareStatement(query); //set username stmt.setString(1, loginInput.getUsername()); //Execute sql satatement to obtain account from database rs = stmt.executeQuery(); while (rs != null && rs.next()) { String password = rs.getString(1); if (password.equals(loginInput.getPassword())) { return new AuthenticationResponse(true); } else { errors = "Login failed. Please try again."; } } } catch (SQLException ex) { ex.printStackTrace(); } finally { ConnectionManager.close(conn, stmt, rs); } return new AuthenticationResponse(false, errors); }
From source file:com.jci.po.apis.FlatFileClient.java
/** * Processing error flat files./*from ww w . j av a2s . c o m*/ * * @param req the req * @return the response entity */ @RequestMapping(value = "/processErrorPosFlatFiles", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE, produces = { MediaType.APPLICATION_JSON_VALUE }) public ResponseEntity<ProcessErrorRes> processErrorPosFlatFiles(@RequestBody ProcessErrorReq req);
From source file:com.rplt.studioMusik.controller.LoginMemberController.java
@RequestMapping(method = { RequestMethod.GET, RequestMethod.POST }) public String validateLoginMember(@RequestParam("username") String username, @RequestParam("password") String password, ModelMap model) { int validateLogin = member.validateLogin(username, password); switch (validateLogin) { case 0://from ww w. j av a2 s.c o m //unregistered model.addAttribute("message", "Unregistered username!"); return "redirect:home/member"; case 1: //wrong password model.addAttribute("message", "Wrong password!"); return "redirect:home/member"; case 2: session.setAttribute("name", member.getNamaByUser(username).toUpperCase()); session.setAttribute("noTelp", member.getNoTelpByUser(username)); session.setAttribute("username", username.toUpperCase()); return "redirect:/member/halamanutamamember"; default: break; } return null; }
From source file:com.pablinchapin.tiendaliz.controller.IdeaController.java
@RequestMapping(method = RequestMethod.POST) public Idea add(@RequestBody Idea idea) { Idea model = new Idea(); model.setCreatedAt(new Date()); model.setTitle(idea.getTitle());//from ww w . j a v a 2s . c o m model.setDescription(idea.getDescription()); return ideaRepository.saveAndFlush(model); }
From source file:butla.springapp.SampleController.java
@RequestMapping(value = "/", method = RequestMethod.POST) @ResponseBody/*from w ww . j a v a 2 s.com*/ public HashMap<String, String> forBenchmark(@RequestBody HashMap<String, String> request) { HashMap<String, String> filtered = new HashMap<String, String>(); for (Map.Entry<String, String> entry : request.entrySet()) { if (entry.getKey().toLowerCase().startsWith("a")) { filtered.put(entry.getKey(), entry.getValue()); } } return filtered; }
From source file:com.artivisi.server.test.web.PenjualanController.java
@RequestMapping(method = RequestMethod.POST) public void create(@RequestBody Penjualan penjualan) { penjualanDao.save(penjualan); }
From source file:edu.umuc.cmsc495.trackit.controllers.LoginResetController.java
@RequestMapping(method = RequestMethod.POST) public String loginReset(@RequestParam("email") String email, ModelMap map) { // Getting all Logins boolean foundEmail = false; List<Login> allLogins = DatastoreSingleton.getAllLogins(); for (Login login : allLogins) { if (login.getEmail().equals(email)) { foundEmail = true;//w ww. j a va 2s.com break; } } // If found, we'll let them know if (foundEmail) { map.addAttribute("msgClass", "text-success"); map.addAttribute("msg", "Found your email, your password has been reset, please check your email!"); } else { map.addAttribute("msgClass", "text-danger"); map.addAttribute("msg", "Your email address was NOT found, try again!"); } // Must return name of file (minus .jsp) under /views return "login-reset"; }
From source file:com.tsg.sitemapwebappmvc.controller.LuckyController.java
@RequestMapping(value = "/LuckyController", method = RequestMethod.POST) public String getLuckyResults(HttpServletRequest request, Model model) { startBet = (Integer.parseInt(request.getParameter("myRolls"))); rollDice(startBet);// w ww .j a v a 2s .c om int rolls = stats.getTotalRolls(); int bestRoll = stats.getMaxDollarRolls(); int bestBet = stats.getMaxDollars(); request.setAttribute("startBet", startBet); request.setAttribute("rolls", rolls); request.setAttribute("bestRoll", bestRoll); request.setAttribute("bestBet", bestBet); return "luckyresponse"; }
From source file:org.beast.project.template.web.HomeController.java
@RequestMapping(value = "/result", method = RequestMethod.POST) public String processForm(@RequestParam("fName") String fName, @RequestParam("lName") String lName) { Person p = new Person(); p.setFirstName(fName);//from ww w . j a va 2 s . c o m p.setLastName(lName); personService.add(p); return "result"; }