List of usage examples for org.springframework.web.servlet ModelAndView setViewName
public void setViewName(@Nullable String viewName)
From source file:it.smartcommunitylab.aac.controller.GlobalDefaultExceptionHandler.java
public ModelAndView resolveException(HttpServletRequest aReq, HttpServletResponse aRes, Object aHandler, Exception anExc) {/*from w ww . ja v a 2s.c o m*/ // hack. should be done better in configuration if ("/oauth/token".equals(aReq.getServletPath())) { return null; } // Otherwise setup and send the user to a default error-view. ModelAndView mav = new ModelAndView(); mav.addObject("exception", anExc); mav.addObject("url", aReq.getRequestURL()); mav.setViewName(DEFAULT_ERROR_VIEW); logger.error("Global erro handler", anExc); return mav; }
From source file:com.hortonworks.example.ambari.AmbariController.java
@RequestMapping(value = "/ambari", method = RequestMethod.GET) public ModelAndView ambari() { ModelAndView model = new ModelAndView(); model.addObject("title", "Ambari Mock UI"); model.addObject("message", "This is protected page!"); model.setViewName("ambari"); return model; }
From source file:org.motechproject.server.demo.web.CallMeController.java
@Override public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception { response.setContentType("text/html"); response.setCharacterEncoding("UTF-8"); String phoneNumber = request.getParameter("phone"); int delay = Integer.parseInt(request.getParameter("callDelay")); Calendar now = Calendar.getInstance(); now.add(Calendar.MINUTE, delay); Date callTime = now.getTime(); ModelAndView mav = new ModelAndView(); demoService.schedulePhoneCall(phoneNumber, callTime); mav.setViewName("successView"); return mav;//from w w w . j a v a2s . c o m }
From source file:br.com.helio.pocspringmvc.web.ProdutoController.java
@RequestMapping(value = "/editar", method = RequestMethod.GET) public ModelAndView editar(@RequestParam("codigo") String codigo) { ModelAndView modelAndView = new ModelAndView(); modelAndView.addObject("produto", produtService.findByCodigo(codigo)); modelAndView.setViewName("produto/add"); return modelAndView; }
From source file:org.owasp.webgoat.controller.About.java
/** * <p>welcome.</p>/*from w w w . j a va 2 s . c o m*/ * * @param request a {@link javax.servlet.http.HttpServletRequest} object. * @param error a {@link java.lang.String} object. * @param logout a {@link java.lang.String} object. * @return a {@link org.springframework.web.servlet.ModelAndView} object. */ @RequestMapping(value = "about.mvc", method = RequestMethod.GET) public ModelAndView welcome(HttpServletRequest request, @RequestParam(value = "error", required = false) String error, @RequestParam(value = "logout", required = false) String logout) { // set the welcome attribute // this is so the attack servlet does not also // send them to the welcome page HttpSession session = request.getSession(); if (session.getAttribute(WELCOMED) == null) { session.setAttribute(WELCOMED, "true"); } //go ahead and send them to webgoat (skip the welcome page) ModelAndView model = new ModelAndView(); //model.setViewName("welcome"); //model.setViewName("main_new"); model.setViewName("about"); return model; }
From source file:org.owasp.webgoat.controller.Welcome.java
/** * <p>welcome.</p>//from w ww. ja v a2 s . c o m * * @param request a {@link javax.servlet.http.HttpServletRequest} object. * @param error a {@link java.lang.String} object. * @param logout a {@link java.lang.String} object. * @return a {@link org.springframework.web.servlet.ModelAndView} object. */ @RequestMapping(value = "welcome.mvc", method = RequestMethod.GET) public ModelAndView welcome(HttpServletRequest request, @RequestParam(value = "error", required = false) String error, @RequestParam(value = "logout", required = false) String logout) { // set the welcome attribute // this is so the attack servlet does not also // send them to the welcome page HttpSession session = request.getSession(); if (session.getAttribute(WELCOMED) == null) { session.setAttribute(WELCOMED, "true"); } //go ahead and send them to webgoat (skip the welcome page) ModelAndView model = new ModelAndView(); //model.setViewName("welcome"); //model.setViewName("main_new"); model.setViewName("forward:/attack?start=true"); return model; }
From source file:ru.trett.cis.controllers.DeviceTypeController.java
@RequestMapping(value = "/{id}") public ModelAndView showUpdateForm(@PathVariable("id") String id, ModelAndView mv) { mv.addObject("deviceType", inventoryService.findById(DeviceType.class, Long.parseLong(id))); mv.setViewName("devicetype/form"); return mv;//from w ww . j a va 2s. c o m }
From source file:com.castlemock.web.basis.web.mvc.controller.LoginController.java
/** * The login method examines the status of the current user and determines which action should be taken. * The following outcomes are possible:/*from ww w. ja va2s . c o m*/ * 1. The user is already logged in, then the user should be redirected to the main page. * 2. The user is not logged in and will try to login. The user will get to the login * view page. If the user have logged out and been redirected to the login page, the a message * should be displayed informing the user that they have been successfully logged out. Another * message could be displayed if the user provided invalid login credentials or if the login * didn't work. * to the page * @param error The error message if a logged in failed due to various reasons * @param logout The logout variable is use to determined if user has been logged out and redirected to the login page. * @param request The login request, which contains the specific error event * @return The login view (With special messages in case of any specific event has occurred). */ @RequestMapping(method = RequestMethod.GET) public ModelAndView login(@RequestParam(value = "error", required = false) final String error, @RequestParam(value = "logout", required = false) final String logout, final HttpServletRequest request) { if (isLoggedIn()) { LOGGER.debug("User is already logged in. Redirecting the user."); return redirect(); } final ModelAndView model = createModelAndView(); model.setViewName(PAGE); model.addObject(DEMO_MODE, demoMode); if (error != null) { LOGGER.debug("Unable to login"); model.addObject(ERROR, getErrorMessage(request, SPRING_SECURITY_LAST_EXCEPTION)); } if (logout != null) { LOGGER.debug("Logout successful"); model.addObject(MSG, messageSource.getMessage("general.login.label.logoutsuccessful", null, LocaleContextHolder.getLocale())); } return model; }
From source file:org.guanxi.sp.engine.form.RegisterIdPFormController.java
@SuppressWarnings("unchecked") public ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object command, BindException errors) throws Exception { File newIdPFile = new File(config.getIdPMetadataDirectory(), request.getParameter("filename") + ".xml"); createIdPFile(newIdPFile, request.getParameter("entityID"), request.getParameter("aa"), request.getParameter("x509").replaceAll("\r", "")); EntityDescriptorDocument loadedIdPDocument = EntityDescriptorDocument.Factory.parse(newIdPFile); EntityFarm farm = (EntityFarm) config.getServletContext() .getAttribute(Guanxi.CONTEXT_ATTR_ENGINE_ENTITY_FARM); // The source is defined in config/spring/application/entity.xml EntityManager manager = farm.getEntityManagerForSource("local-metadata"); Metadata metadataHandler = manager.createNewEntityHandler(); metadataHandler.setPrivateData(loadedIdPDocument.getEntityDescriptor()); manager.addMetadata(metadataHandler); ModelAndView mAndV = new ModelAndView(); mAndV.setViewName(getSuccessView()); mAndV.getModel().put("message", messageSource.getMessage("register.idp.success.message", null, request.getLocale())); return mAndV; }
From source file:com.mycompany.springmvcaccount.controller.HelloController.java
@RequestMapping(value = "/hello/{person}/{country}", method = RequestMethod.GET) public ModelAndView showHello(@PathVariable(value = "person") String person, @PathVariable(value = "country") String country) { ModelAndView modelView = new ModelAndView(); modelView.addObject("message", "Hello " + person + " from " + country); modelView.setViewName("hello"); // name of jsp page return modelView; }