ModelMap addAttribute - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for ModelMap addAttribute method.

This code example shows how to use the following methods:addAttribute
 
	@RequestMapping("/common/v_image_area_select.do") 
	public String imageAreaSelect(String uploadBase, String imgSrcPath,
			Integer zoomWidth, Integer zoomHeight, Integer uploadNum,
			HttpServletRequest request, ModelMap model) {
		model.addAttribute("uploadBase", uploadBase);
		model.addAttribute("imgSrcPath", imgSrcPath);
		model.addAttribute("zoomWidth", zoomWidth);
		model.addAttribute("zoomHeight", zoomHeight);
		model.addAttribute("uploadNum", uploadNum);
		return IMAGE_SELECT_RESULT;
	} 
 
	@RequestMapping("/common/o_image_cut.do") 
	public String imageCut(String imgSrcPath, Integer imgTop, Integer imgLeft,
			Integer imgWidth, Integer imgHeight, Integer reMinWidth,
			Integer reMinHeight, Float imgScale, Integer uploadNum,
			HttpServletRequest request, ModelMap model) {
		CmsSite site = CmsUtils.getSite(request);
		try { 
6
CodeRank
This code example shows how to use the following methods:addAttribute
    @Autowired 
    ApprovalService approvalService;
 
    @RequestMapping(value="id-{id}/approve", method=RequestMethod.POST)
    public ModelMap approve(@PathVariable(value="id") Long id) throws Exception {
        ModelMap model = new ModelMap();
        Object result = approvalService.approve(id);
        if(result.toString().startsWith("Error")) {
            model.addAttribute("status", "error");
        } else { 
            model.addAttribute("status", "success");
        } 
        model.addAttribute("result", result);
        return model;
    } 
 
    @RequestMapping(value="id-{id}/reject", method=RequestMethod.POST)
    public ModelMap reject(@PathVariable(value="id") Long id) throws Exception {
        ModelMap model = new ModelMap();
        approvalService.reject(id);
6
CodeRank
This code example shows how to use the following methods:addAttribute, get
 
	// 直接调用方法需要把root参数保存至model中 
	@RequestMapping(value = "/file/v_list.do") 
	public String list(HttpServletRequest request, ModelMap model) {
		CmsSite site = CmsUtils.getSite(request);
		String root = (String) model.get("root");
		if (root == null) {
			root = RequestUtils.getQueryParam(request, "root");
		} 
		String valid=RequestUtils.getQueryParam(request, "valid");
		Boolean validB=null;
		if(StringUtils.isNotBlank(valid)){
			if(valid.equals("1")){
				validB=true;
			}else{ 
				validB=false;
			} 
		} 
		log.debug("list Resource root: {}", root);
		if (StringUtils.isBlank(root)) {

6
CodeRank
This code example shows how to use the following methods:addAttribute
		return memberEdit(request, model);
	} 
 
	@RequestMapping("/config/v_login_edit.do") 
	public String loginEdit(HttpServletRequest request, ModelMap model) {
		model.addAttribute("configLogin", configMng.getConfigLogin());
		model.addAttribute("emailSender", configMng.getEmailSender());
		model.addAttribute("forgotPasswordTemplate", configMng.getForgotPasswordMessageTemplate());
		model.addAttribute("registerTemplate", configMng.getRegisterMessageTemplate());
		return "config/login_edit"; 
	} 
 
	@RequestMapping("/config/o_login_update.do") 
	public String loginUpdate(ConfigLogin configLogin,
			ConfigEmailSender emailSender, ConfigMessageTemplate msgTpl,
			HttpServletRequest request, ModelMap model) {
		configMng.updateOrSave(configLogin.getAttr());
		configMng.updateOrSave(emailSender.getAttr());
		configMng.updateOrSave(msgTpl.getAttr());
		model.addAttribute("message", "global.success");
6
CodeRank
This code example shows how to use the following methods:addAttribute
		 
		Writer stringWriter = new StringWriter();
		PrintWriter printWriter = new PrintWriter(stringWriter);
		ex.printStackTrace(printWriter);
		 
		ModelMap model = new ModelMap();
		model.addAttribute("error", ex);
		model.addAttribute("stackTrace", stringWriter.toString());
		return new ModelAndView("/error", model);
	} 
	 
	@ExceptionHandler(Exception.class)
	public ModelAndView handleException(Exception ex) {
		logger.info("Catching: " + ex.getClass().getSimpleName());
		logger.error(ex.getMessage(), ex);
		return error(ex);
	} 
 
 
} 
6
CodeRank
This code example shows how to use the following methods:addAttribute
		long freeMemoery = runtime.freeMemory();
		long totalMemory = runtime.totalMemory();
		long usedMemory = totalMemory - freeMemoery;
		long maxMemory = runtime.maxMemory();
		long useableMemory = maxMemory - totalMemory + freeMemoery;
		model.addAttribute("props", props);
		model.addAttribute("freeMemoery", freeMemoery);
		model.addAttribute("totalMemory", totalMemory);
		model.addAttribute("usedMemory", usedMemory);
		model.addAttribute("maxMemory", maxMemory);
		model.addAttribute("useableMemory", useableMemory);
		model.addAttribute("version", version);
		model.addAttribute("user", user);
		model.addAttribute("flowMap", cmsStatisticSvc.getWelcomeSiteFlowData(site.getId()));
		return "right"; 
	} 
 
	@Autowired 
	private CmsSiteMng cmsSiteMng;
	@Autowired 
6
CodeRank
This code example shows how to use the following methods:addAttribute
	public ModelMap getModel() {
		if (useDefaultModel()) { 
			return this.defaultModel;
		} 
		else { 
			return (this.redirectModel != null) ? this.redirectModel : new ModelMap();
		} 
	} 
 
	/** 
	 * Whether to use the default model or the redirect model. 
	 */ 
	private boolean useDefaultModel() { 
		return (!this.redirectModelScenario || (this.redirectModel == null && !this.ignoreDefaultModelOnRedirect));
	} 
 
	/** 
	 * Provide a separate model instance to use in a redirect scenario. 
	 * The provided additional model however is not used used unless 
	 * {@link #setRedirectModelScenario(boolean)} gets set to {@code true} to signal 

6
CodeRank
This code example shows how to use the following methods:addAttribute
	} 
 
	private void putCommonData(CmsStatisticModel statisticModel,
			List<CmsStatistic> list, Integer year, Integer month, Integer day,
			ModelMap model) {
		model.addAttribute("list", list);
		model.addAttribute("total", getTotal(list));
		model.addAttribute("statisticModel", statisticModel.name());
		model.addAttribute("year", year);
		model.addAttribute("month", month);
		model.addAttribute("day", day);
	} 
 
	private Long getTotal(List<CmsStatistic> list) {
		return list.size() > 0 ? list.iterator().next().getTotal() : 0L;
	} 
 
	@Autowired 
	private ChannelMng channelMng;
	@Autowired 
6
CodeRank
This code example shows how to use the following methods:addAttribute
    @RequestMapping("/mobile/oauth2/authorize") 
    /** 
     * A simple login form without register button 
     */ 
    public String oauth2Authorize(ModelMap model) {
        model.addAttribute("release", env.get("release"));
        model.addAttribute("name", "The Upgrade");
        model.addAttribute("description", "The Upgrade brings together self trackers and personal data specialists in a unique platform to build the knowledge that will one day empower every human on earth to realize their full potential.");
        return "oauth2/Authorize"; 
    } 
 
 
    @RequestMapping("/mobile/authenticate") 
    /** 
     * A simple login form without register button 
     */ 
    public String authenticate(ModelMap model) {
        model.addAttribute("release", env.get("release"));
        return "mobile/authenticate"; 
    } 
6
CodeRank
This code example shows how to use the following methods:addAttribute
	private static final int LIMIT = 15;
	 
	@RequestMapping("/profile/{type}/{projectId}") 
	public String profile(@PathVariable("type") String type, @PathVariable("projectId") Long projectId, 
			Long moduleId, ModelMap modelMap, @RequestParam(defaultValue="1")int page) {
		modelMap.addAttribute("modules", moduleService.queryModules(projectId));
		modelMap.addAttribute("configs", configService.queryConfigs(projectId, moduleId, PageUtil.getOffset(page, LIMIT), LIMIT));
		modelMap.addAttribute("moduleId", moduleId);
		modelMap.addAttribute("project", projectService.queryProject(projectId));
		 
		long recordCount = configService.queryConfigCount(projectId, moduleId);
		modelMap.addAttribute("totalPages", PageUtil.pageCount(recordCount, LIMIT));
		modelMap.addAttribute("currentPage", page);
		 
		return "profile/" + type;
	} 
	 
	@RequestMapping("/profile/preview/{projectCode}/{type}") 
	public String preview(@PathVariable("type") String type, @PathVariable("projectCode") String projectCode, 
			Long projectId, ModelMap modelMap) {
6
CodeRank
addAttribute Method Overview
Add the supplied attribute to this Map using a generated name.
See Code Examples for other Spring Framework ModelMap Methods: