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:sample.jpa.web.IndexController.java

@GetMapping("/")
@Transactional(readOnly = true)//  ww  w.  ja  v a2  s.com
public ModelAndView index() {
    List<Note> notes = this.noteRepository.findAll();
    ModelAndView modelAndView = new ModelAndView("index");
    modelAndView.addObject("notes", notes);
    return modelAndView;
}

From source file:br.com.joaops.smt.controller.HomeController.java

@RequestMapping(value = "/", method = RequestMethod.GET)
public ModelAndView index(HttpServletRequest request, HttpServletResponse response, Pageable p) {
    ModelAndView mav = new ModelAndView("home/index");
    mav.addObject("user", systemUserService.getUserByEmail(request.getRemoteUser()));
    mav.addObject("empresas", empresaService.searchAllEmpresa(p));
    return mav;//from  w w  w  .j a  v a2 s.c  om
}

From source file:com.banco.controller.UserController.java

@RequestMapping(value = "/registrar", method = RequestMethod.GET)
public ModelAndView registrar(Model model) {
    ModelAndView modelAndView = new ModelAndView("registrar");
    modelAndView.addObject("Usuario", new User());
    return modelAndView;
}

From source file:me.bulat.jivr.webmin.web.defended.user.Nodes.java

@RequestMapping(value = { "/user/nodes" }, method = { RequestMethod.GET })
public ModelAndView nodesPage() {
    NodeRowList nodes = consul.getNodeList();
    ModelAndView model = new ModelAndView();
    model.addObject("title", "Jivr Web Console Nodes page");
    model.addObject("message", "Nodes Page!");
    model.addObject("nodes", nodes);
    model.setViewName("user/nodes");
    return model;
}

From source file:ru.trett.cis.controllers.CostCenterController.java

@RequestMapping(value = "/{id}")
public ModelAndView showUpdateForm(@PathVariable("id") String id, ModelAndView mv) {
    mv.addObject("costCenter", inventoryService.findById(CostCenter.class, Long.parseLong(id)));
    mv.setViewName("costcenter/form");
    return mv;//from   w  w w  .j  av a2 s  .c o  m
}

From source file:it.jugpadova.controllers.EventSearchController.java

@RequestMapping
protected ModelAndView search(@ModelAttribute("eventSearch") EventSearch eventSearch) {
    List<Event> events = eventBo.search(eventSearch);
    ModelAndView mv = new ModelAndView("event/search");
    mv.addObject("events", events);
    mv.addObject("showNoResultsMessage", Boolean.toString(events.isEmpty()));
    return mv;//  w w  w.  j a v  a 2  s .  c o m
}

From source file:com.fengduo.bee.web.controller.cms.CMSController.java

/**
 * /*from ww  w  .j a va  2 s .  c o  m*/
 * 
 * @return
 */
@RequestMapping(value = "/help/{name}")
public ModelAndView help(@PathVariable("name") String name) {
    ModelAndView mav = new ModelAndView("cms/" + name);
    mav.addObject("name", name);
    return mav;
}

From source file:com.neupane.springJDBC.controller.CustomerControler.java

@RequestMapping(method = RequestMethod.GET)
public ModelAndView index() throws ClassNotFoundException, SQLException {
    ModelAndView mv = new ModelAndView("index");
    try {//from  w w w .  j  a  v a2  s  .  c om
        mv.addObject("customer", customerDAO.getAll());
    } catch (SQLException sql) {
        System.out.println(sql.getMessage());
    }
    return mv;
}

From source file:edu.hm.muse.controller.SearchController.java

    @RequestMapping
   (value = "/search.secu", 
   method = RequestMethod.POST)//from  w  w w.j  av a  2 s .c o  m
public ModelAndView searchWebWithPost
   (@RequestParam
      (value = "search", 
      required = false) 
      String search) {
   ModelAndView mv = new ModelAndView("search");
   mv.addObject("searchString", search);
   return mv;
   }

From source file:fr.patouche.data.jpa.web.SampleController.java

@RequestMapping("/test")
@Transactional(readOnly = true)//from   w  w  w  .  j a  v  a 2s . c om
public ModelAndView helloWorld(Pageable pageable) {
    Page<City> cities = this.cityService.getCities(pageable);
    ModelAndView mv = new ModelAndView("testView");
    mv.addObject("cities", cities);
    return mv;
}