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.MyHistory.Controller.EquipoController.java

@RequestMapping(value = "/ResultadoRegistroEquipo", method = RequestMethod.GET)
public ModelAndView resultadoRegistrarEquipo(HttpServletRequest pRequest) {
    String respuesta = pRequest.getParameter("respuesta");
    ModelAndView mv = new ModelAndView();
    mv.addObject("respuesta", respuesta);
    mv.setViewName("ResultadoRegistro");
    return mv;/* w  w  w.  j av  a  2  s  . c om*/
}

From source file:com.naver.timetable.controller.AdminController.java

@RequestMapping(value = "/userList")
public ModelAndView userList(UserSearchParam searchParam) {
    ModelAndView mv = new ModelAndView("userList");
    mv.addObject("userList", userBO.getUsers(searchParam));
    mv.addObject("searchParam", searchParam);
    return mv;/*from  www  . j a  va 2  s.  c o m*/
}

From source file:controller.DeleteCustomerController.java

protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response)
        throws Exception {
    String customer_id = request.getParameter("id");
    System.out.println("Prdouct id: " + customer_id);

    ApplicationContext context = new ClassPathXmlApplicationContext("Beans.xml");

    HttpSession session = request.getSession();
    session.setAttribute("successmsg", "Customer Deleted Successfully");

    DbTable Delete_customer = (DbTable) context.getBean("DbTable");
    DbTable customerMng = (DbTable) context.getBean("DbTable");

    Delete_customer.DeleteCustomer(customer_id);

    ModelAndView model = new ModelAndView("ListCustomer");
    model.addObject("list", customerMng.getCustomer());
    return model;
}

From source file:com.naver.timetable.controller.LectureController.java

 @RequestMapping(value = "/index")
public ModelAndView index(HttpServletRequest request)   {
   ModelAndView mv = new ModelAndView("lectureIndex");
   mv.addObject("categoryGroup", categoryBO.getAllCategoryByGroup());
   mv.addObject("weekdays", TableParsingBO.WEEKDAY);
   return mv;/*from   w w  w  .  j  av a2 s .c o  m*/
}

From source file:edu.lfa.df.controller.MainController.java

@RequestMapping(value = { "/", "/welcome/**" }, method = RequestMethod.GET)
public ModelAndView defaultPage() {

    ModelAndView model = new ModelAndView();
    model.addObject("title", "Spring Security Login Form - Database Authentication");
    model.addObject("message", "This is default page!");
    model.setViewName("hello");
    return model;

}

From source file:edu.lfa.df.controller.MainController.java

@RequestMapping(value = "/admin**", method = RequestMethod.GET)
public ModelAndView adminPage() {

    ModelAndView model = new ModelAndView();
    model.addObject("title", "Spring Security Login Form - Database Authentication");
    model.addObject("message", "This page is for ROLE_ADMIN only!");
    model.setViewName("admin");
    return model;

}

From source file:io.springagora.store.web.controllers.CategoryWebController.java

@RequestMapping(value = "/{id}", method = RequestMethod.GET)
public ModelAndView findCategoryById(@PathVariable Long id) {
    Category selectedCategory = Category.findOne(id);
    if (selectedCategory != null) {
        ModelAndView mav = new ModelAndView("productsInCategory");
        mav.addObject("categories", Category.findAll());
        mav.addObject("selectedCategory", selectedCategory);
        mav.addObject("products", selectedCategory.getProducts());
        return mav;
    }/*from   w  w w  .ja  v  a 2 s.  c om*/
    throw new EntityNotFoundException("Sorry, I couldn't find this category.");
}

From source file:uta.ak.usttmp.console.controller.TopicTrackingController.java

@RequestMapping("/trackingTopic")
public ModelAndView trackingTopic(String taskId) {

    String sql = "select * from c_miningtask where mme_eid=?";
    MiningTask task = (MiningTask) usttmpJdbcTemplate.queryForObject(sql, new MiningTaskRowMapper(), taskId);

    ModelAndView mav = new ModelAndView("trackingTopic");
    mav.addObject("task", task);
    mav.addObject("basicWidth", task.getQrtzJobExecCount() * 500);
    mav.addObject("basicHeight", task.getTopicNum() * 50);
    mav.addObject("topicNum", task.getTopicNum());
    return mav;//from w w  w .j  a  v a 2  s.  c  o  m
}

From source file:com.castlemock.web.basis.web.mvc.controller.ViewControllerAdvice.java

/**
 * Handles uncaught exceptions and creates an error view that will be displayed to the user.
 * @param request The request that originally caused the exception
 * @param exception The uncaught exception
 * @return Returns a view that displays the exception message
 *//*from   w  w w.j a v a 2  s  . c  o  m*/
@ResponseBody
@ExceptionHandler(value = Exception.class)
public ModelAndView defaultErrorViewHandler(HttpServletRequest request, Exception exception) {
    LOGGER.error("The following request failed: " + request.getRequestURI() + " (" + request.getMethod() + ")");
    LOGGER.error(exception.getMessage(), exception);
    ModelAndView model = createPartialModelAndView(PAGE);
    model.addObject(TITLE, "An error occurred");
    model.addObject(MESSAGE, exception.getMessage());
    return model;
}

From source file:com.opencart.controller.MainController.java

@RequestMapping(value = "/subcategory", method = RequestMethod.GET)
public ModelAndView showSubCategory(HttpServletRequest request) {
    ModelAndView mv = new ModelAndView("front/subcategory");
    mv.addObject("subcategories", subcategoryService.list());
    mv.addObject("categories", categoryService.list());
    mv.addObject("products", productService.getBySubCategoryId(Integer.parseInt(request.getParameter("id"))));
    return mv;/*from  w  w  w  .  j  a v  a  2  s.  c  o  m*/
}