Java Code Examples for org.springframework.web.servlet.view.RedirectView#setUrl()
The following examples show how to use
org.springframework.web.servlet.view.RedirectView#setUrl() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: StudentLoginController.java From Spring-MVC-Blueprints with MIT License | 6 votes |
@RequestMapping(method=RequestMethod.POST) public RedirectView submitForm(Model model, @Validated @ModelAttribute LoginForm studLoginForm, BindingResult bindingResult){ model.addAttribute("studLoginForm", studLoginForm); RedirectView redirectView = new RedirectView(); redirectView.setContextRelative(true); if(bindingResult.hasErrors()) { studLoginForm = new LoginForm(); redirectView.setUrl("/smp/stud_login.html"); model.addAttribute("studLoginForm", studLoginForm); } else{ Login login = new Login(); login.setUserName(studLoginForm.getUsername()); login.setPassWord(studLoginForm.getPassword()); System.out.println("controller"+login.getUserName()); if(loginService.isStudentUser(login)){ redirectView.setUrl("/smp/stud_enroll.html"); model.addAttribute("studId", reportService.getStudentId(login.getUserName()).getStudentId()); }else{ studLoginForm = new LoginForm(); redirectView.setUrl("/smp/stud_login.html"); } } return redirectView; }
Example 2
Source File: AdminDepartmentFromController.java From Spring-MVC-Blueprints with MIT License | 6 votes |
@RequestMapping(method=RequestMethod.POST) public RedirectView submitForm(Model model, @Validated @ModelAttribute("deptForm") DepartmentForm deptForm, BindingResult bindingResult){ model.addAttribute("deptForm", deptForm); RedirectView redirectView = new RedirectView(); redirectView.setContextRelative(true); redirectView.setUrl("/smp/admin_add_department.html"); List<Tbldepartment> depts = reportService.getAllDepartment(); model.addAttribute("depts", depts); if(bindingResult.hasErrors()) { deptForm = new DepartmentForm(); model.addAttribute("deptForm", deptForm); } else{ managementService.addDepartment(deptForm); deptForm = new DepartmentForm(); model.addAttribute("deptForm", deptForm); } return redirectView; }
Example 3
Source File: StudentEnrollController.java From Spring-MVC-Blueprints with MIT License | 6 votes |
@RequestMapping(method=RequestMethod.POST) public RedirectView submitForm(Model model, HttpServletRequest request, @Validated @ModelAttribute ListAvailCourseForm listForm, BindingResult bindingResult){ model.addAttribute("listForm", listForm); RedirectView redirectView = new RedirectView(); redirectView.setContextRelative(true); if(bindingResult.hasErrors()) { redirectView.setUrl("/smp/stud_enroll.html"); listForm = enrollmentService.listForm(); model.addAttribute("listForm", listForm); } else{ int studentId = (Integer) request.getSession().getAttribute("studId"); enrollmentService.enroll(listForm,studentId); listForm = enrollmentService.listForm(); redirectView.setUrl("/smp/stud_enroll.html"); } return redirectView; }
Example 4
Source File: StudentLoginController.java From Spring-MVC-Blueprints with MIT License | 6 votes |
@RequestMapping(method=RequestMethod.POST) public RedirectView submitForm(Model model, @Validated @ModelAttribute LoginForm studLoginForm, BindingResult bindingResult){ model.addAttribute("studLoginForm", studLoginForm); RedirectView redirectView = new RedirectView(); redirectView.setContextRelative(true); if(bindingResult.hasErrors()) { studLoginForm = new LoginForm(); redirectView.setUrl("/smp/stud_login.html"); model.addAttribute("studLoginForm", studLoginForm); } else{ Login login = new Login(); login.setUserName(studLoginForm.getUsername()); login.setPassWord(studLoginForm.getPassword()); if(loginService.isStudentUser(login)){ redirectView.setUrl("/smp/stud_enroll.html"); model.addAttribute("studId", reportService.getStudentId(login.getUserName()).getStudentId()); }else{ studLoginForm = new LoginForm(); redirectView.setUrl("/smp/stud_login.html"); } } return redirectView; }
Example 5
Source File: AdminFacultyFormController.java From Spring-MVC-Blueprints with MIT License | 6 votes |
@RequestMapping(method=RequestMethod.POST) public RedirectView submitForm(Model model, @Validated @ModelAttribute("facultyForm") FacultyForm facultyForm, BindingResult bindingResult){ model.addAttribute("facultyForm", facultyForm); RedirectView redirectView = new RedirectView(); redirectView.setContextRelative(true); redirectView.setUrl("/smp/admin_add_faculty.html"); List<Tblfaculty> faculty = reportService.getAllFaculty(); model.addAttribute("faculty", faculty); references(model); if(bindingResult.hasErrors()) { facultyForm = new FacultyForm(); model.addAttribute("facultyForm", facultyForm); } else{ managementService.addFaculty(facultyForm); facultyForm = new FacultyForm(); model.addAttribute("facultyForm", facultyForm); } return redirectView; }
Example 6
Source File: FacultyLoginController.java From Spring-MVC-Blueprints with MIT License | 6 votes |
@RequestMapping(method=RequestMethod.POST) public RedirectView submitForm(Model model, @Validated @ModelAttribute LoginForm facultyLoginForm, BindingResult bindingResult){ model.addAttribute("facultyLoginForm", facultyLoginForm); RedirectView redirectView = new RedirectView(); redirectView.setContextRelative(true); if(bindingResult.hasErrors()) { facultyLoginForm = new LoginForm(); redirectView.setUrl("/smp/faculty_login.html"); model.addAttribute("facultyLoginForm", facultyLoginForm); } else{ Login login = new Login(); login.setUserName(facultyLoginForm.getUsername()); login.setPassWord(facultyLoginForm.getPassword()); if(loginService.isFacultyUser(login)){ model.addAttribute("facultyId", reportService.getFacultyId(login.getUserName()).getFacultyId()); redirectView.setUrl("/smp/faculty_masterlist.html"); }else{ facultyLoginForm = new LoginForm(); redirectView.setUrl("/smp/faculty_login.html"); } } return redirectView; }
Example 7
Source File: AdminController.java From Spring-MVC-Blueprints with MIT License | 6 votes |
@RequestMapping("/smp/admin_logout.html") public RedirectView logout(Model model, HttpServletRequest req){ RedirectView redirectView = new RedirectView(); redirectView.setContextRelative(true); redirectView.setUrl("/smp/admin_login.html"); long end = 0; long start = 0; try{ end = (Long) req.getSession().getAttribute("timeUsed"); start = (Long) req.getSession().getAttribute("timeStarted"); }catch(NullPointerException e){ end = 0; start = 0; } long accessTime = (start-end)/1000; model.addAttribute("accessTime", accessTime); return redirectView; }
Example 8
Source File: AdminDepartmentFromController.java From Spring-MVC-Blueprints with MIT License | 6 votes |
@RequestMapping(method=RequestMethod.POST) public RedirectView submitForm(Model model, @Validated @ModelAttribute("deptForm") DepartmentForm deptForm, BindingResult bindingResult){ model.addAttribute("deptForm", deptForm); RedirectView redirectView = new RedirectView(); redirectView.setContextRelative(true); redirectView.setUrl("/smp/admin_add_department.html"); List<Tbldepartment> depts = reportService.getAllDepartment(); model.addAttribute("depts", depts); if(bindingResult.hasErrors()) { deptForm = new DepartmentForm(); model.addAttribute("deptForm", deptForm); } else{ managementService.addDepartment(deptForm); deptForm = new DepartmentForm(); model.addAttribute("deptForm", deptForm); } return redirectView; }
Example 9
Source File: CategoryController.java From podcastpedia-web with MIT License | 6 votes |
/** * Custom handler for displaying a podcast. * * @param podcastId * @param episode * @return */ @RequestMapping(value="{categoryId}/*", method=RequestMethod.GET) public ModelAndView getPodcastsFromCategory(@PathVariable("categoryId") int categoryId, ModelMap model){ LOG.debug("------ CategoryController.getPodcastsFromCategory : redirects to search podcasts from a given category -----"); StringBuffer queryString = new StringBuffer(); queryString.append("?numberResultsPerPage=10"); queryString.append("&searchTarget=podcasts"); queryString.append("&categId=" + categoryId); queryString.append("&searchMode=natural"); queryString.append("¤tPage=1"); String url = "/search/advanced_search/results" + queryString.toString(); RedirectView rv = new RedirectView(); rv.setStatusCode(HttpStatus.MOVED_PERMANENTLY); rv.setUrl(url); ModelAndView mv = new ModelAndView(rv); return mv; }
Example 10
Source File: FacultyLoginController.java From Spring-MVC-Blueprints with MIT License | 6 votes |
@RequestMapping(method=RequestMethod.POST) public RedirectView submitForm(Model model, @Validated @ModelAttribute LoginForm facultyLoginForm, BindingResult bindingResult){ model.addAttribute("facultyLoginForm", facultyLoginForm); RedirectView redirectView = new RedirectView(); redirectView.setContextRelative(true); if(bindingResult.hasErrors()) { facultyLoginForm = new LoginForm(); redirectView.setUrl("/smp/faculty_login.html"); model.addAttribute("facultyLoginForm", facultyLoginForm); } else{ Login login = new Login(); login.setUserName(facultyLoginForm.getUsername()); login.setPassWord(facultyLoginForm.getPassword()); if(loginService.isFacultyUser(login)){ model.addAttribute("facultyId", reportService.getFacultyId(login.getUserName()).getFacultyId()); redirectView.setUrl("/smp/faculty_masterlist.html"); }else{ facultyLoginForm = new LoginForm(); redirectView.setUrl("/smp/faculty_login.html"); } } return redirectView; }
Example 11
Source File: AdminLoginController.java From Spring-MVC-Blueprints with MIT License | 6 votes |
@RequestMapping(method=RequestMethod.POST) public RedirectView submitForm(Model model, @Validated @ModelAttribute LoginForm adminLoginForm, BindingResult bindingResult){ model.addAttribute("adminLoginForm", adminLoginForm); RedirectView redirectView = new RedirectView(); redirectView.setContextRelative(true); if(bindingResult.hasErrors()) { adminLoginForm = new LoginForm(); redirectView.setUrl("/smp/admin_login.html"); model.addAttribute("adminLoginForm", adminLoginForm); } else{ Login login = new Login(); login.setUserName(adminLoginForm.getUsername()); login.setPassWord(adminLoginForm.getPassword()); if(loginService.isAdminUser(login)){ redirectView.setUrl("/smp/admin_pending.html"); }else{ adminLoginForm = new LoginForm(); redirectView.setUrl("/smp/admin_login.html"); } } return redirectView; }
Example 12
Source File: AdminFacultyFormController.java From Spring-MVC-Blueprints with MIT License | 6 votes |
@RequestMapping(method=RequestMethod.POST) public RedirectView submitForm(Model model, @Validated @ModelAttribute("facultyForm") FacultyForm facultyForm, BindingResult bindingResult){ model.addAttribute("facultyForm", facultyForm); RedirectView redirectView = new RedirectView(); redirectView.setContextRelative(true); redirectView.setUrl("/smp/admin_add_faculty.html"); List<Tblfaculty> faculty = reportService.getAllFaculty(); model.addAttribute("faculty", faculty); references(model); if(bindingResult.hasErrors()) { facultyForm = new FacultyForm(); model.addAttribute("facultyForm", facultyForm); } else{ managementService.addFaculty(facultyForm); facultyForm = new FacultyForm(); model.addAttribute("facultyForm", facultyForm); } return redirectView; }
Example 13
Source File: StudentEnrollController.java From Spring-MVC-Blueprints with MIT License | 6 votes |
@RequestMapping(method=RequestMethod.POST) public RedirectView submitForm(Model model, HttpServletRequest request, @Validated @ModelAttribute ListAvailCourseForm listForm, BindingResult bindingResult){ model.addAttribute("listForm", listForm); RedirectView redirectView = new RedirectView(); redirectView.setContextRelative(true); if(bindingResult.hasErrors()) { redirectView.setUrl("/smp/stud_enroll.html"); listForm = enrollmentService.listForm(); model.addAttribute("listForm", listForm); } else{ int studentId = (Integer) request.getSession().getAttribute("studId"); enrollmentService.enroll(listForm,studentId); listForm = enrollmentService.listForm(); redirectView.setUrl("/smp/stud_enroll.html"); } return redirectView; }
Example 14
Source File: StudentEnrollController.java From Spring-MVC-Blueprints with MIT License | 6 votes |
@RequestMapping(method=RequestMethod.POST) public RedirectView submitForm(Model model, HttpServletRequest request, @Validated @ModelAttribute ListAvailCourseForm listForm, BindingResult bindingResult){ model.addAttribute("listForm", listForm); RedirectView redirectView = new RedirectView(); redirectView.setContextRelative(true); if(bindingResult.hasErrors()) { redirectView.setUrl("/smp/stud_enroll.html"); listForm = enrollmentService.listForm(); model.addAttribute("listForm", listForm); } else{ int studentId = (Integer) request.getSession().getAttribute("studId"); enrollmentService.enroll(listForm,studentId); listForm = enrollmentService.listForm(); redirectView.setUrl("/smp/stud_enroll.html"); } return redirectView; }
Example 15
Source File: AdminDepartmentFromController.java From Spring-MVC-Blueprints with MIT License | 6 votes |
@RequestMapping(method=RequestMethod.POST) public RedirectView submitForm(Model model, @Validated @ModelAttribute("deptForm") DepartmentForm deptForm, BindingResult bindingResult){ model.addAttribute("deptForm", deptForm); RedirectView redirectView = new RedirectView(); redirectView.setContextRelative(true); redirectView.setUrl("/smp/admin_add_department.html"); List<Tbldepartment> depts = reportService.getAllDepartment(); model.addAttribute("depts", depts); if(bindingResult.hasErrors()) { deptForm = new DepartmentForm(); model.addAttribute("deptForm", deptForm); } else{ managementService.addDepartment(deptForm); deptForm = new DepartmentForm(); model.addAttribute("deptForm", deptForm); } return redirectView; }
Example 16
Source File: FeedbackController.java From Spring-MVC-Blueprints with MIT License | 5 votes |
@RequestMapping(value = "/cfs/feedbacks/{topicId}/{id}/delete", method = RequestMethod.POST) public RedirectView deleteFeedback(@PathVariable("topicId") int topicId,@PathVariable("id") int id, final RedirectAttributes redirectAttributes) { feedbackService.removeFeedback(topicId, id); redirectAttributes.addFlashAttribute("css", "success"); redirectAttributes.addFlashAttribute("msg", "Feedback is deleted!"); RedirectView redirectView = new RedirectView(); redirectView.setContextRelative(true); redirectView.setUrl("/cfs/feedback_update/"+topicId); return redirectView; }
Example 17
Source File: SignUpController.java From Spring-MVC-Blueprints with MIT License | 5 votes |
@RequestMapping(method=RequestMethod.POST) public RedirectView submitForm(Model model, @ModelAttribute LoginForm signupForm, BindingResult bindingResult){ model.addAttribute("signupForm", signupForm); RedirectView redirectView = new RedirectView(); redirectView.setContextRelative(true); if(bindingResult.hasErrors()) { signupForm = new LoginForm(); redirectView.setUrl("/ocs/signup"); references(model); model.addAttribute("signupForm", signupForm); } else{ loginService.addAccount(signupForm); IdentityService identityService = processEngine.getIdentityService(); User user = identityService.newUser(signupForm.getUsername()); user.setPassword(signupForm.getPassword()); identityService.saveUser(user); try{ identityService.saveGroup(identityService.newGroup("payor")); identityService.saveGroup(identityService.newGroup("shipper")); identityService.saveGroup(identityService.newGroup("shopper")); identityService.saveGroup(identityService.newGroup("buyer")); }catch(Exception e){ System.out.println("Groups already exists...."); } identityService.createMembership(signupForm.getUsername(), "shopper"); identityService.createMembership(signupForm.getUsername(), "buyer"); identityService.createMembership(signupForm.getUsername(), "payor"); identityService.createMembership(signupForm.getUsername(), "shipper"); redirectView.setUrl("/ocs/login"); } return redirectView; }
Example 18
Source File: TopicController.java From Spring-MVC-Blueprints with MIT License | 5 votes |
@RequestMapping(value = "/cfs/topics/{id}/delete", method = RequestMethod.POST) public RedirectView deleteUser(@PathVariable("id") int id, final RedirectAttributes redirectAttributes) { topicService.removeTopic(id); redirectAttributes.addFlashAttribute("css", "success"); redirectAttributes.addFlashAttribute("msg", "Topic is deleted!"); RedirectView redirectView = new RedirectView(); redirectView.setContextRelative(true); redirectView.setUrl("/cfs/topics.html"); return redirectView; }
Example 19
Source File: FeedbackFormController.java From Spring-MVC-Blueprints with MIT License | 5 votes |
@RequestMapping(value = "/cfs/feedback_process_edit", method = RequestMethod.POST) public RedirectView submitForUpdate( @ModelAttribute("feedbackForm") @Validated FeedbackForm feedbackForm, HttpServletRequest request, BindingResult result, Model model, final RedirectAttributes redirectAttributes) { RedirectView redirectView = new RedirectView(); redirectView.setContextRelative(true); System.out.println("form: " + feedbackForm.getTopicId()); System.out.println("form: " + feedbackForm.getId()); redirectView.setUrl("/cfs/feedbacks/" + feedbackForm.getTopicId()); if (result.hasErrors()) { redirectView.setUrl("/cfs/feedbacks/" + feedbackForm.getTopicId()); } else { redirectAttributes.addFlashAttribute("css", "success"); String answer = request.getParameter("simpleCaptchaAnswer"); HttpSession session = request.getSession(); if (validateSimpleCaptcha(session, answer)) { redirectAttributes.addFlashAttribute("msg", "Feedback "+ feedbackForm.getId() +" updated successfully!"); feedbackService.updateFeedback(feedbackForm.getTopicId(), feedbackForm); } else { redirectView.setUrl("/cfs/feedbacks/"+feedbackForm.getTopicId()+"/"+feedbackForm.getId()+"/update"); } } return redirectView; }
Example 20
Source File: TopicFormController.java From Spring-MVC-Blueprints with MIT License | 5 votes |
@RequestMapping(value = "/cfs/topic_process_add", method = RequestMethod.POST) public RedirectView submitForAdd( @ModelAttribute("topicForm") @Validated TopicForm topicForm, HttpServletRequest request, BindingResult result, Model model, final RedirectAttributes redirectAttributes, @RequestParam("recaptcha_challenge_field") String challangeField, @RequestParam("recaptcha_response_field") String responseField) { RedirectView redirectView = new RedirectView(); redirectView.setContextRelative(true); redirectView.setUrl("/cfs/topics.html"); if (result.hasErrors()) { redirectView.setUrl("/cfs/topics.html"); } else { redirectAttributes.addFlashAttribute("css", "success"); String remoteAddress = request.getRemoteAddr(); ReCaptchaResponse reCaptchaResponse = this.reCaptcha.checkAnswer( remoteAddress, challangeField, responseField); if (reCaptchaResponse.isValid()) { redirectAttributes.addFlashAttribute("msg", "New topic added successfully!"); topicService.addTopic(topicForm); redirectView.setUrl("/cfs/topics.html"); } else { redirectView.setUrl("/cfs/topics_add.html"); } } return redirectView; }