Example usage for org.springframework.web.servlet ModelAndView addObject

List of usage examples for org.springframework.web.servlet ModelAndView addObject

Introduction

In this page you can find the example usage for org.springframework.web.servlet ModelAndView addObject.

Prototype

public ModelAndView addObject(String attributeName, @Nullable Object attributeValue) 

Source Link

Document

Add an attribute to the model.

Usage

From source file:com.hugoangeles.demospringhibernate.controller.HomeController.java

@RequestMapping("/list")
public ModelAndView list() {
    ModelAndView mv = new ModelAndView("list");
    mv.addObject("contacts", contactService.listAll());
    return mv;/*from w ww  .j  av a  2s  . c  o  m*/
}

From source file:com.iopr.controllers.KonfiguratorController.java

@RequestMapping("/")
public ModelAndView index(@RequestParam(value = "name", required = false, defaultValue = "World") String name) {
    List<Configurable> products = (List<Configurable>) ProductsDAO.getInstance().readAll(Products.class);
    ModelAndView model = new ModelAndView("index");
    model.addObject("name", name);
    model.addObject("products", products);
    return model;
}

From source file:com.leapfrog.lfaeventmanager.admin.controller.PersonController.java

@RequestMapping(value = "index", method = RequestMethod.GET)
public ModelAndView index() {
    ModelAndView mv = new ModelAndView("person/index");
    mv.addObject("personList", personService.getAll());
    return mv;//www  .  j av  a  2 s  .  c om
}

From source file:com.leapfrog.springhibernate.controller.MeetupController.java

@RequestMapping(value = "index", method = RequestMethod.GET)
public @ResponseBody ModelAndView index() {
    ModelAndView mv = new ModelAndView("meetup/index");
    mv.addObject("meetupList", meetupService.getAll());
    return mv;/*from   ww  w  .  j a  va2  s.  c om*/
}

From source file:com.mc.controller.HelloController.java

@RequestMapping("/hi/{countryName}/{cityName}/{userName}")
public ModelAndView hiWorld(@PathVariable Map<String, String> pathVars) {

    String user = pathVars.get("userName");
    String city = pathVars.get("cityName");
    String country = pathVars.get("countryName");

    ModelAndView model = new ModelAndView("index");
    model.addObject("welcomeMessage", "Hi " + user + ". You are from " + city + ", " + country);
    return model;
}

From source file:org.jtalks.jcommune.web.controller.AnswerController.java

@RequestMapping(method = RequestMethod.GET, value = "/answer")
public ModelAndView answer(@RequestParam("topicId") Long topicId) {
    logger.info("Answering to the topic " + topicId);
    if (securityService.getCurrentUser() != null) {
        ModelAndView mav = new ModelAndView("answer");
        mav.addObject("topicId", topicId);
        return mav;
    } else {//from  w  w  w  .j a  v  a2 s. c o  m
        logger.info("User doesn't logged in. Redirect to the login page");
        return new ModelAndView("redirect:/login.html");
    }
}

From source file:com.controller.TelefonosController.java

@RequestMapping(value = "editar.htm", method = RequestMethod.GET)
public ModelAndView editar(HttpServletRequest request) {
    Telefonos telefono = new Telefonos();
    TelefonosDao dao = new TelefonosDao();
    telefono.setTelefono(request.getParameter("telefono"));
    telefono = dao.getTelefono(telefono.getTelefonoArea());
    ModelAndView mav = new ModelAndView();
    mav.addObject("usuario", telefono);
    mav.setViewName("telefonos/editar");
    return mav;/*from   w  ww  .  j a v  a 2  s .com*/
}

From source file:com.havoc.hotel.admin.controller.UserController.java

@RequestMapping(value = "/add", method = RequestMethod.GET)
public ModelAndView adduser() throws SQLException {
    ModelAndView mv = new ModelAndView("/admin/users/add");
    mv.addObject("User", new User());
    return mv;// w ww.  j  a  v a  2 s. com
}

From source file:com.havoc.hotel.admin.controller.UserController.java

@RequestMapping(value = "/edit/{user_id}", method = RequestMethod.GET)
public ModelAndView edit(@PathVariable("user_id") int userId) throws SQLException {
    ModelAndView mv = new ModelAndView("admin/users/edit");
    mv.addObject("User", userDAO.getById(userId));
    return mv;/*www.  ja  va  2  s  .c  o m*/
}

From source file:com.library.bookarticlelibrary.controller.AuthorsController.java

@RequestMapping(value = "/authors/author/{authorId}", method = RequestMethod.GET)
public ModelAndView displayAuthor(@PathVariable("authorId") int authorId) {
    Author author = authorDao.get(authorId);
    ModelAndView model = new ModelAndView("author");
    model.addObject("title", "authors");
    model.addObject("author", author);

    return model;
}