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:Controller.MeetingController.java

@RequestMapping("/welcome")
protected ModelAndView handleRequestInternal(HttpServletRequest hsr, HttpServletResponse hsr1)
        throws Exception {
    ModelAndView modelandview = new ModelAndView("index");
    modelandview.addObject("welcomeMessage", "Hi user, welcome to the first MVC app");

    return modelandview;
}

From source file:org.openmrs.module.vcttrac.web.controller.VCTGraphicalStatisticPerDayController.java

/**
 * @see org.springframework.web.servlet.mvc.ParameterizableViewController#handleRequestInternal(javax.servlet.http.HttpServletRequest,
 *      javax.servlet.http.HttpServletResponse)
 *//*from   w ww  . j  a v a 2s  .c om*/
@Override
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response)
        throws Exception {
    ModelAndView mav = new ModelAndView();
    mav.addObject("todayDate", Context.getDateFormat().format(new Date()));
    mav.setViewName(getViewName());

    return mav;
}

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

@RequestMapping(value = "/{id}")
public ModelAndView showForm(@PathVariable("id") String id, ModelAndView mv) {
    mv.addObject("asset", inventoryService.findById(Asset.class, Long.parseLong(id)));
    mv.addObject("statuses", Asset.Status.values());
    mv.setViewName("asset/form");
    return mv;/*  w  w w .j av a  2 s.co m*/
}

From source file:ua.com.codefire.testhiber.web.IndexController.java

@RequestMapping(value = "/index", method = RequestMethod.GET)
public ModelAndView getIndex() {
    ModelAndView mav = new ModelAndView("index");
    mav.addObject("studentList", studentRepository.findAll());

    return mav;/* w w w  . j  ava2 s.  c o m*/
}

From source file:com.baron.bm.controller.ExceptionHandlerController.java

@ExceptionHandler(BindException.class)
public ModelAndView handleException(BindException error, HttpServletResponse response) throws Exception {
    ModelAndView mav = new ModelAndView("/common/backScript");
    mav.addObject("errorMessage", error.getFieldError().getDefaultMessage());
    return mav;//  ww  w  .j a  va  2  s  . c om
}

From source file:com.havoc.hotel.controller.CustomerController.java

@RequestMapping(value = "/customerdetail/{username}", method = RequestMethod.GET)
public ModelAndView userdetail(@PathVariable("username") String username) throws SQLException {
    ModelAndView mv = new ModelAndView("customer/index");
    mv.addObject("customer", customerDAO.getByUsername(username));
    return mv;/*ww  w.j a v a 2  s . c om*/
}

From source file:com.leapfrog.inventorymanagementsystem.controller.admin.DashboardController.java

@RequestMapping(method = RequestMethod.GET)
public ModelAndView index() {
    ModelAndView mv = new ModelAndView("/admin/index");
    mv.addObject("title", "Admin !");
    return mv;/*from w w w  .j a va  2s.c  om*/
}

From source file:com.miko.demo.mongo.controller.MainController.java

@RequestMapping(value = "entityA", method = RequestMethod.GET)
public ModelAndView getEntityAMain(ModelAndView model) {
    model.addObject("message", "Hello Spring 4 MongoDB Demo and AngularJS!");
    model.setViewName("hello");
    return model;
}

From source file:com.miko.demo.neo4j.controller.MainController.java

@RequestMapping(value = "entityA", method = RequestMethod.GET)
public ModelAndView getEntityAMain(ModelAndView model) {
    model.addObject("message", "Hello Spring 4 Neo4J Demo and AngularJS!");
    model.setViewName("hello");
    return model;
}

From source file:com.miko.demo.postgresql.controller.MainController.java

@RequestMapping(value = "entityA", method = RequestMethod.GET)
public ModelAndView getEntityAMain(ModelAndView model) {
    model.addObject("message", "Hello Spring 4 PostgreSQL Demo and AngularJS!");
    model.setViewName("hello");
    return model;
}