List of usage examples for org.springframework.web.servlet ModelAndView addObject
public ModelAndView addObject(String attributeName, @Nullable Object attributeValue)
From source file:com.castlemock.web.mock.soap.web.mvc.controller.event.SoapEventController.java
/** * The method provides the functionality to retrieve a specific SOAP event * @param eventId The id of the SOAP event that should be retrieved * @return A view that displays the retrieved SOAP event *///from www . j a v a 2s . com @PreAuthorize("hasAuthority('READER') or hasAuthority('MODIFIER') or hasAuthority('ADMIN')") @RequestMapping(value = "soap/event/{eventId}", method = RequestMethod.GET) public ModelAndView defaultPage(@PathVariable final String eventId) { final ReadSoapEventOutput output = serviceProcessor.process(new ReadSoapEventInput(eventId)); final ModelAndView model = createPartialModelAndView(PAGE); model.addObject(EVENT, output.getSoapEvent()); return model; }
From source file:com.gemtastic.lillakammaren.controller.IndexController.java
@RequestMapping(value = "/", method = RequestMethod.GET) public ModelAndView index() throws IOException { this.repository = ProductRepository.getInstance(); ModelAndView model = new ModelAndView(); model.setViewName("index"); model.addObject("categories", repository.getAllCategories()); model.addObject("cartsize", cart.getCartSize()); return model; }
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; }
From source file:com.work.petclinic.web.GeneralController.java
@RequestMapping("/unauthorized") public ModelAndView accessDenied() { ModelAndView mav = new ModelAndView(); mav.addObject("timestamp", new Date()); mav.setViewName("unauthorized"); return mav;/*from www . jav a2 s.c o m*/ }
From source file:org.jboss.spring3_2.example.ControllerAdvice.mvc.MemberControllerAdvice.java
@ExceptionHandler(value = Exception.class) public ModelAndView exception(Exception e) { ModelAndView model = new ModelAndView("error"); model.addObject("error", getStackTrace(e)); return model; }
From source file:rashjz.info.com.az.config.AdviceController.java
@ExceptionHandler(value = Exception.class) public ModelAndView defaultErrorHandler(HttpServletRequest req, Exception e) throws Exception { // If the exception is annotated with @ResponseStatus rethrow it and let // the framework handle it - like the OrderNotFoundException example // at the start of this post. // AnnotationUtils is a Spring Framework utility class. if (AnnotationUtils.findAnnotation(e.getClass(), ResponseStatus.class) != null) { throw e;/*from w w w.ja v a 2 s .com*/ } // Otherwise setup and send the user to a default error-view. ModelAndView mav = new ModelAndView(); mav.addObject("exception", e); mav.addObject("url", req.getRequestURL()); mav.setViewName(DEFAULT_ERROR_VIEW); return mav; }
From source file:com.castlemock.web.mock.rest.web.mvc.controller.event.RestEventController.java
/** * The method provides the functionality to retrieve a REST event. * @param eventId The id of the event that should be retrieved * @return View with the specific REST event *///ww w . ja v a 2 s .co m @PreAuthorize("hasAuthority('READER') or hasAuthority('MODIFIER') or hasAuthority('ADMIN')") @RequestMapping(value = "rest/event/{eventId}", method = RequestMethod.GET) public ModelAndView defaultPage(@PathVariable final String eventId) { final ReadRestEventOutput output = serviceProcessor.process(new ReadRestEventInput(eventId)); final ModelAndView model = createPartialModelAndView(PAGE); model.addObject(EVENT, output.getRestEvent()); return model; }
From source file:com.excilys.ebi.bank.web.interceptor.page.WebPageModelAttributeHandlerInterceptor.java
@Override protected void postHandleInternal(HttpServletRequest request, HttpServletResponse response, HandlerMethod handlerMethod, ModelAndView modelAndView, Map<String, ?> pathVariables) throws Exception { modelAndView.addObject(WebPage.PAGE_MODEL, getAnnotation(handlerMethod).value()); }
From source file:com.intel.cosbench.driver.web.MissionPageController.java
protected ModelAndView process(MissionInfo info) { ModelAndView result = new ModelAndView("mission"); result.addObject("info", info); result.addObject("isStopped", isStopped(info.getState())); result.addObject("isRunning", isRunning(info.getState())); result.addObject("toBeAuthed", allowAuth(info.getState())); result.addObject("toBeLaunched", allowLaunch(info.getState())); result.addObject("toBeClosed", allowClose(info.getState())); return result; }
From source file:org.zols.web.interceptor.PagePopulationInterceptor.java
@Override public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception { if (modelAndView != null) { modelAndView.addObject("links", linkService.getApplicationLinks()); modelAndView.addObject("viewName", modelAndView.getViewName()); modelAndView.setViewName("index"); }/*from w w w .j a v a2s . co m*/ }