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:ru.trett.cis.controllers.EmployeeController.java

@RequestMapping(value = "/{id}")
public ModelAndView showUpdateForm(@PathVariable("id") String id, ModelAndView mv) {
    mv.addObject("employee", inventoryService.findById(Employee.class, Long.parseLong(id)));
    mv.setViewName("employee/form");
    return mv;//from   w w  w. j  a  v  a  2  s  .  c  o m
}

From source file:com.faisal.controllers.HelloWorld.java

@RequestMapping(value = "/", method = RequestMethod.GET)
public ModelAndView getdata() {
    System.out.println("-------------------ccccccccccccc----------------");
    List<String> list = getList();
    ModelAndView model = new ModelAndView("hello");
    model.addObject("msg", "ni ssss");
    model.addObject("lists", list);
    model.addObject("student", new Student());
    model.addObject("list", getStudentsList());
    //        Student s = studentDao.findStudent("faisal");
    //        System.out.println(s.getLastName());
    //        model.addObject("name", s.getFirstName()+ " "+s.getLastName());
    return model;

}

From source file:com.intel.cosbench.controller.web.WorkloadSubmissionController.java

private ModelAndView createSuccResult(String id) {
    ModelAndView result = new ModelAndView("submit");
    result.addObject("aInfos", controller.getActiveWorkloads());
    result.addObject("submitted", "your workload has been accepted");
    result.addObject("id", id);
    return result;
}

From source file:com.klm.workshop.controller.participant.TargetBehaviorController.java

/**
 * Show panel with verbs for the "Define Target Behavior" part
 * /*  www  . j av  a2  s  . co  m*/
 * @param model Objects and view
 * @return Panel with the verbs for selecting the Target Behavior
 */
@RequestMapping(value = "/index", method = RequestMethod.GET)
public ModelAndView index(ModelAndView model) {
    model.addObject("workshopStep", CURRENT_STEP);
    model.addObject("verbs", getVerbsForCurrentSession());
    model.setViewName(VIEW_FOLDER + "/index");
    return model;
}

From source file:com.tce.spring.oauth2.controller.LoginController.java

@RequestMapping(value = "/login", method = RequestMethod.GET)
public ModelAndView login(@RequestParam(value = "error", required = false) String error,
        @RequestParam(value = "logout", required = false) String logout) {

    ModelAndView model = new ModelAndView();
    if (error != null) {
        model.addObject("error", "Invalid username and password!");
    }/*from   w ww .  j  a v  a  2  s  .c o  m*/
    if (logout != null) {
        model.addObject("msg", "You've been logged out successfully.");
    }
    model.setViewName("login");
    return model;
}

From source file:de.interseroh.report.controller.ConfigSetter.java

public void setVersion(ModelAndView modelAndView) {
    String version = env.getProperty("version");
    modelAndView.addObject("version", version);
}

From source file:io.hedwig.petclinic.ui.web.GeneralController.java

@ExceptionHandler(Exception.class)
public ModelAndView handleException(HttpServletRequest req, Exception e) {
    logger.debug("In handleException");

    ModelAndView mav = new ModelAndView();
    mav.addObject("exception", e);
    mav.addObject("timestamp", new Date());
    mav.addObject("url", req.getRequestURL());
    mav.setViewName("exception");
    return mav;/*from   www .ja v  a2s .c o m*/
}

From source file:com.alibaba.intl.bcds.goldroom.web.ReservatedBooksController.java

@SuppressWarnings("unchecked")
@Override/*from   ww  w .  j  a v a 2s .  c o  m*/
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response)
        throws Exception {

    String pageStr = request.getParameter("page");
    String pagesizeStr = request.getParameter("pagesize");
    Result result = bookItemService.listReservatedBooksBySubscriber(UserUtil.getLoginId(),
            NumberUtils.toInt(pageStr, 1), NumberUtils.toInt(pagesizeStr, 10));
    Map<String, Object> map = (Map<String, Object>) result.getReturnObject();
    ModelAndView mv = new ModelAndView("user/reservatedBooks");
    mv.addObject("bookItemList", map.get("bookItemList"));
    mv.addObject("pageNavView", PageUtils.createPageNavView((Integer) map.get("totalCount"), request));
    return mv;
}

From source file:com.tongji.collaborationteam.pagecontrollers.IndexController.java

@RequestMapping(value = "/index", params = "log_out")
public ModelAndView log_out(HttpSession session) {
    //  session.removeAttribute("session_user");
    session.invalidate();/*  w w w  .  j  a va 2s .c  o m*/
    ModelAndView mv = new ModelAndView("redirect:index", "myinfo", new MyInfo());
    mv.addObject("login_info", new MyInfo());
    return mv;

}

From source file:com.gian.controller.SecurityController.java

@RequestMapping(value = "logout", method = RequestMethod.POST)
public ModelAndView logout() {

    Session session = HibernateConfiguration.getSessionFactory().getCurrentSession();
    session.close();/*from www  .  ja  v a 2  s .  co m*/

    _log.info("Session Logout...");
    ModelAndView mv = new ModelAndView("index");
    mv.addObject("messageFromController", "SecurityController Logout!");
    return mv;

}