List of usage examples for org.springframework.web.servlet ModelAndView addObject
public ModelAndView addObject(String attributeName, @Nullable Object attributeValue)
From source file:com.library.bookarticlelibrary.controller.BooksController.java
@RequestMapping(value = "/books/book/{bookId}", method = RequestMethod.GET) public ModelAndView displayBook(@PathVariable("bookId") int bookId) { Book book = bookDao.get(bookId); ModelAndView model = new ModelAndView("book"); model.addObject("book", book); return model; }
From source file:com.stephengream.simplecms.web.controllers.AuthController.java
@RequestMapping(value = "login", method = RequestMethod.GET) public ModelAndView login(@RequestParam(value = "error", required = false) String error, @RequestParam(value = "logout", required = false) String logout) { //Not sure why, but CSRF protection wouldn't work without using this //way of doing things ModelAndView model = new ModelAndView(); if (error != null) { model.addObject("error", "Invalid username and password!"); }// w w w. ja v a 2 s.co m if (logout != null) { model.addObject("msg", "You've been logged out successfully."); } model.setViewName("auth/login"); return model; }
From source file:controller.Crud.java
@RequestMapping(value = "/edit/{id}", method = RequestMethod.GET) public ModelAndView edit(@PathVariable("id") String id) { Hallo h = config.mahasiswa(id);// w ww . j a v a 2 s . co m ModelAndView andView = new ModelAndView("crud/edit"); andView.addObject("command", h); andView.addObject("id", id); return andView; }
From source file:controller.MakeAgenda.java
@RequestMapping(method = RequestMethod.GET) public ModelAndView makeAppointment() { ModelAndView modelandview = new ModelAndView("makeAgenda", "appointment", new Agenda()); modelandview.addObject("doctors", service.getDoctors()); return modelandview; }
From source file:ua.aits.oblenergo_site.controller.SystemController.java
@RequestMapping(value = { "/system/menu", "/system/menu/" }, method = RequestMethod.GET) public ModelAndView menu(HttpServletRequest request, HttpServletResponse response) throws SQLException, ClassNotFoundException, InstantiationException, IllegalAccessException, ParseException { ModelAndView model = new ModelAndView("/system/menu"); model.addObject("menuList", Helpers.getRowHtmlList("ua", "0")); return model; }
From source file:br.vschettino.forum.controller.DiscussaoController.java
@RequestMapping(value = { "/", "/list" }) public ModelAndView lista() { List<Discussao> listDiscussao = discussaoDAO.list(); ModelAndView model = new ModelAndView("discussoes"); model.addObject("listDiscussao", listDiscussao); return model; }
From source file:com.castlemock.web.basis.web.mvc.controller.project.CreateProjectController.java
/** * The method create a view that displays all required attributes needed * for creating a new project.//from w w w . jav a 2 s .com * @return A view that displays all required attributes for creating a new project. */ @PreAuthorize("hasAuthority('MODIFIER') or hasAuthority('ADMIN')") @RequestMapping(method = RequestMethod.GET) public ModelAndView defaultPage() { final ModelAndView model = createPartialModelAndView(PAGE); model.addObject(PROJECT_TYPES, projectServiceFacade.getTypes()); model.addObject(COMMAND, new CreateProjectCommand()); return model; }
From source file:com.havoc.hotel.admin.controller.CustomerAdminController.java
@RequestMapping(value = "/new", method = RequestMethod.GET) public ModelAndView newbooking() throws SQLException { ModelAndView mv = new ModelAndView("admin/customer/newcustomer"); mv.addObject("Customer", customerDAO.getLast()); return mv;/* w w w . j a va 2 s . c o m*/ }
From source file:edu.infsci2560.controllers.DvdEditController.java
@RequestMapping(value = "dvds/edit/{id}", method = RequestMethod.GET) public ModelAndView index(@PathVariable Long id) { ModelAndView mv = new ModelAndView("dvdEdit"); Dvd dvd = dvdRepository.findOne(id); mv.addObject("dvd", dvd); // mv.addObject("ratings", ratingRepository.findAll()); mv.addObject("ratings", ratingRepository.findByRatingPkDvdId(dvd.getId(), new PageRequest(0, 10))); return mv;//from w ww . j ava 2s . c o m }
From source file:org.logger.event.web.spring.exception.EventExceptionResolver.java
@Override public ModelAndView doResolveException(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) {/*from ww w . j av a 2s. co m*/ ErrorObject errorObject = null; ex.printStackTrace(); logger.error("Error in Resolver : {}", ex); if (ex instanceof AccessDeniedException) { errorObject = new ErrorObject(403, ex.getMessage()); response.setStatus(403); } else if (ex instanceof SizeLimitExceededException) { response.setStatus(HttpServletResponse.SC_REQUEST_ENTITY_TOO_LARGE); errorObject = new ErrorObject(413, ex.getMessage()); } else if (ex instanceof S3ServiceException) { response.setStatus(500); errorObject = new ErrorObject(500, ((S3ServiceException) ex).getErrorMessage()); } else { errorObject = new ErrorObject(500, ex.getMessage()); response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); } ModelAndView jsonModel = new ModelAndView("rest/model"); jsonModel.addObject("model", new JSONSerializer().exclude("*.class").serialize(errorObject)); return jsonModel; }