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.aerolinea.control.ControlIndex.java

@RequestMapping(value = "/", method = GET)
public ModelAndView mostrarIndex(@RequestParam("texto") String texto) {
    ModelAndView mv = new ModelAndView("index");
    mv.addObject("mensaje", "Hola 1 " + texto);
    return mv;//from w  ww.j  a  v a2s. c  om
}

From source file:com.aerolinea.control.ControlIndex.java

@RequestMapping("/home/{texto}")
public ModelAndView mostrarIndex2(@PathVariable("texto") String texto) {
    ModelAndView mv = new ModelAndView("index");
    mv.addObject("mensaje", "Hola 2 " + texto);
    return mv;//from   ww  w  . j  a va2 s.co m
}

From source file:com.griddynamics.banshun.web.NestedController.java

public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    String message = "Hello Spring MVC";

    ModelAndView modelAndView = new ModelAndView("testView");
    modelAndView.addObject("message", message);

    return modelAndView;
}

From source file:com.mycompany.springmvcaccount.controller.UserController.java

@RequestMapping(value = "/register")
public ModelAndView showFormRegister() {
    ModelAndView mv = new ModelAndView();
    mv.addObject("user", new User());
    mv.addObject("gender", Gender.values());
    mv.addObject("countries", countries);
    mv.setViewName("registerForm");

    return mv;//  w w  w.  j a va  2 s.c o m
}

From source file:com.technologicaloddity.saha.controller.IndexController.java

@RequestMapping("/index.html")
public ModelAndView handleRequest(Model model) {
    Metadata nameMetadata = metadataDao.getNameMetadata();

    ModelAndView modelAndView = new ModelAndView("index");
    modelAndView.addObject("nameMetadata", nameMetadata);
    return modelAndView;
}

From source file:com.ignite.controller.TellerController.java

@RequestMapping(value = "/teller", method = RequestMethod.GET)
public ModelAndView clients() {
    List<Client> clients = clientDao.getClients();
    ModelAndView mav = new ModelAndView("teller");
    mav.addObject("clientList", clients);
    return mav;//from  w w w  .  j a v  a  2s. c o m
}

From source file:com.orchestra.portale.controller.AllPoisIdController.java

@RequestMapping(value = "/poiId")
public ModelAndView listid() {
    Iterable<CompletePOI> poilist = pm.getAllCompletePoi();
    ArrayList<String> idlist = new ArrayList<String>();
    int i = 1;//from w  w w.  ja v  a  2  s .  co m
    for (CompletePOI poi : poilist) {
        idlist.add(i + ") " + poi.getId());
        i++;
    }
    ModelAndView model = new ModelAndView("poilist");
    model.addObject("lista", idlist);
    return model;
}

From source file:com.stitchgalaxy.sg_manager_web.GlobalDefaultExceptionHandler.java

@ExceptionHandler(value = Exception.class)
public ModelAndView defaultErrorHandler(Exception e) throws Exception {
    // If the exception is annotated with @ResponseStatus rethrow it and let
    // the framework handle it - like the OrderNotFoundException example
    // at the start of this post.
    // AnnotationUtils is a Spring Framework utility class.
    if (AnnotationUtils.findAnnotation(e.getClass(), ResponseStatus.class) != null)
        throw e;/*w w  w  . j  a  va 2s .c o  m*/

    StringWriter sw = new StringWriter();
    PrintWriter pw = new PrintWriter(sw);
    e.printStackTrace(pw);

    ModelAndView mav = new ModelAndView("error");
    mav.addObject("stack_trace", sw.toString());

    return mav;
}

From source file:it.smartcommunitylab.aac.controller.GlobalDefaultExceptionHandler.java

public ModelAndView resolveException(HttpServletRequest aReq, HttpServletResponse aRes, Object aHandler,
        Exception anExc) {/*from  www . j  ava2  s .  co  m*/
    // hack. should be done better in configuration   
    if ("/oauth/token".equals(aReq.getServletPath())) {
        return null;
    }
    // Otherwise setup and send the user to a default error-view.
    ModelAndView mav = new ModelAndView();
    mav.addObject("exception", anExc);
    mav.addObject("url", aReq.getRequestURL());
    mav.setViewName(DEFAULT_ERROR_VIEW);
    logger.error("Global erro handler", anExc);
    return mav;
}

From source file:org.zhangmz.pickles.controller.user.UserMainController.java

@RequestMapping(value = "/main", method = RequestMethod.GET)
public ModelAndView home(@RequestParam("TOKEN") String token) {
    ModelAndView result = new ModelAndView(UserUrl.mainPage);

    result.addObject("TOKEN", token);
    return result;
}