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.intel.cosbench.controller.web.StagePageController.java

protected ModelAndView process(WorkloadInfo wInfo, StageInfo sInfo) {
    ModelAndView result = new ModelAndView("stage");
    result.addObject("sInfo", sInfo);
    result.addObject("wInfo", wInfo);
    result.addObject("isStopped", isStopped(sInfo.getState()));
    result.addObject("isRunning", isRunning(sInfo.getState()));
    return result;
}

From source file:com.bitranger.parknshop.visitor.controller.ProductsCtrl.java

@RequestMapping(value = VisitorView.itemCtrlMapping, method = RequestMethod.GET)
public ModelAndView product(HttpServletRequest request, HttpServletResponse response) {

    List<PsItem> itemList = itemFinderService.getItems(request);
    System.out.println("ProductsCtrl.product()");
    System.out.println(itemList);
    for (PsItem psItem : itemList) {
        psItem.setIntroduction(Utility.slice(psItem.getIntroduction(), 40));
    }//from  w ww.j av  a2s  .  c  o  m

    ModelAndView mv = new ModelAndView();
    mv.addObject(VisitorParams.productItemList, itemList);
    mv.addObject(VisitorParams.itemCount, itemList.size());
    mv.setViewName(VisitorView.product);

    List<PsPromotItem> ads = adCenter.itemAdService.forItemList(itemList, 60, null);
    mv.addObject("ad_list", ads);

    return mv;

}

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

@PreAuthorize("hasAuthority('READER') or hasAuthority('MODIFIER') or hasAuthority('ADMIN')")
@RequestMapping(method = RequestMethod.POST)
public ModelAndView search(@ModelAttribute SearchCommand searchCommand) {
    final String query = searchCommand.getQuery();
    final SearchQuery searchQuery = new SearchQuery();
    searchQuery.setQuery(query);/*from   www  .  ja  va  2  s.  c om*/
    final List<SearchResult> searchResults = projectServiceFacade.search(searchQuery);
    ModelAndView model = createPartialModelAndView(PAGE);
    model.addObject(SEARCH_RESULTS, searchResults);
    return model;
}

From source file:com.mc.controller.HelloController.java

@RequestMapping("/")
public ModelAndView rootWorld() {
    ModelAndView model = new ModelAndView("index");
    model.addObject("welcomeMessage", "Root World");
    return model;
}

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

@RequestMapping(value = "/mailing.secu")
public ModelAndView showAllMailings() {
    String sql = "select * from M_USER";

    List<User> users = jdbcTemplate.query(sql, new UserMapper());

    ModelAndView mv = new ModelAndView("mailing");
    mv.addObject("users", users);
    return mv;/*from  w ww  . jav a2 s . c  om*/
}

From source file:gxu.software_engineering.shen10.market.core.GlobalExceptionHandler.java

/**
 * ??ajaxhtml~//  w  w  w .  j  a  va 2  s.co  m
 * @param t ?
 * @return json or html depends on what the client wants!
 */
@ExceptionHandler(Throwable.class)
public ModelAndView exp(Throwable t) {
    L.error("?", t);
    ModelAndView mav = new ModelAndView(ERROR_PAGE);
    mav.addObject(STATUS, STATUS_NO);
    mav.addObject(MESSAGE, t.getMessage());
    if (t.getCause() != null) {
        mav.addObject(EXP_REASON, t.getCause().getMessage());
    } else {
        mav.addObject(EXP_REASON, UNKNOWN_REASON);
    }
    return mav;
}

From source file:org.darwinathome.server.controller.ExceptionResolver.java

public ModelAndView resolveException(HttpServletRequest httpServletRequest,
        HttpServletResponse httpServletResponse, Object object, Exception exception) {
    String stackTrace = getStackTrace(exception);
    try {/*w ww .j  a v a2s. co  m*/
        Map<String, Object> model = new TreeMap<String, Object>();
        model.put("stackTrace", stackTrace);
        emailSender.sendEmail(targetEmailAddress, "noreply@darwinathome.org", "Exception Occurred", model);
    } catch (Exception e) {
        log.warn("Unable to send email to " + targetEmailAddress, e);
    }
    ModelAndView mav = new ModelAndView("exception");
    mav.addObject("exception", exception);
    mav.addObject("stackTrace", stackTrace);
    return mav;
}

From source file:org.jboss.spring3_2.example.MatrixVariables.mvc.MemberController.java

@RequestMapping(value = "/{filter}", method = RequestMethod.GET)
public ModelAndView filteredMembers(@MatrixVariable(required = false, defaultValue = "") String n,
        @MatrixVariable(required = false, defaultValue = "") String e) {
    ModelAndView model = new ModelAndView("index");
    model.addObject("newMember", new Member());
    List<Member> members = memberDao.findByNameAndEmail(n, e);
    model.addObject("members", members);
    return model;
}

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

@RequestMapping("/index")
public ModelAndView index() {

    ModelAndView mv = new ModelAndView("index", "myinfo", new MyInfo());
    mv.addObject("login_info", new MyInfo());
    return mv;/*from ww  w  .  j  a  va  2  s .c om*/

}

From source file:com.sishuok.chapter3.web.controller.CallableController.java

@RequestMapping("/callable2")
public Callable<ModelAndView> callable2() {
    return new Callable<ModelAndView>() {
        @Override// w ww.  j ava2  s .co m
        public ModelAndView call() throws Exception {
            Thread.sleep(2L * 1000); //?
            ModelAndView mv = new ModelAndView("msg");
            mv.addObject("msg", "hello callable");
            return mv;
        }
    };
}