当前位置: 首页>>代码示例>>Java>>正文


Java ModelAttribute类代码示例

本文整理汇总了Java中org.springframework.web.bind.annotation.ModelAttribute的典型用法代码示例。如果您正苦于以下问题:Java ModelAttribute类的具体用法?Java ModelAttribute怎么用?Java ModelAttribute使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ModelAttribute类属于org.springframework.web.bind.annotation包,在下文中一共展示了ModelAttribute类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: downloadSignedFile

import org.springframework.web.bind.annotation.ModelAttribute; //导入依赖的package包/类
@RequestMapping(value = "/download", method = RequestMethod.GET)
public String downloadSignedFile(@ModelAttribute("signedDocument") InMemoryDocument signedDocument, HttpServletResponse response) {
	try {
		MimeType mimeType = signedDocument.getMimeType();
		if (mimeType != null) {
			response.setContentType(mimeType.getMimeTypeString());
		}
		response.setHeader("Content-Transfer-Encoding", "binary");
		response.setHeader("Content-Disposition", "attachment; filename=\"" + signedDocument.getName() + "\"");
		Utils.copy(new ByteArrayInputStream(signedDocument.getBytes()), response.getOutputStream());

	} catch (Exception e) {
		logger.error("An error occured while pushing file in response : " + e.getMessage(), e);
	}
	return null;
}
 
开发者ID:esig,项目名称:dss-demonstrations,代码行数:17,代码来源:SignatureController.java

示例2: export

import org.springframework.web.bind.annotation.ModelAttribute; //导入依赖的package包/类
@RequestMapping("msg-info-export")
public void export(@ModelAttribute Page page,
        @RequestParam Map<String, Object> parameterMap,
        HttpServletRequest request, HttpServletResponse response)
        throws Exception {
    List<PropertyFilter> propertyFilters = PropertyFilter
            .buildFromMap(parameterMap);
    page = msgInfoManager.pagedQuery(page, propertyFilters);

    List<MsgInfo> msgInfos = (List<MsgInfo>) page.getResult();

    TableModel tableModel = new TableModel();
    tableModel.setName("msg info");
    tableModel.addHeaders("id", "name");
    tableModel.setData(msgInfos);
    exportor.export(request, response, tableModel);
}
 
开发者ID:zhaojunfei,项目名称:lemon,代码行数:18,代码来源:MsgInfoController.java

示例3: save

import org.springframework.web.bind.annotation.ModelAttribute; //导入依赖的package包/类
@RequestMapping("stamp-info-save")
public String save(@ModelAttribute StampInfo stampInfo,
        @RequestParam Map<String, Object> parameterMap,
        RedirectAttributes redirectAttributes) {
    String tenantId = tenantHolder.getTenantId();
    StampInfo dest = null;

    Long id = stampInfo.getId();

    if (id != null) {
        dest = stampInfoManager.get(id);
        beanMapper.copy(stampInfo, dest);
    } else {
        dest = stampInfo;
        dest.setTenantId(tenantId);
    }

    stampInfoManager.save(dest);

    messageHelper.addFlashMessage(redirectAttributes, "core.success.save",
            "保存成功");

    return "redirect:/stamp/stamp-info-list.do";
}
 
开发者ID:zhaojunfei,项目名称:lemon,代码行数:25,代码来源:StampInfoController.java

示例4: listSent

import org.springframework.web.bind.annotation.ModelAttribute; //导入依赖的package包/类
@RequestMapping("msg-info-listSent")
public String listSent(@ModelAttribute Page page,
        @RequestParam Map<String, Object> parameterMap, Model model) {
    String userId = currentUserHolder.getUserId();
    List<PropertyFilter> propertyFilters = PropertyFilter
            .buildFromMap(parameterMap);

    propertyFilters.add(new PropertyFilter("EQS_senderId", userId));
    page.setOrder("DESC");
    page.setOrderBy("createTime");
    page = msgInfoManager.pagedQuery(page, propertyFilters);

    model.addAttribute("page", page);

    return "msg/msg-info-listSent";
}
 
开发者ID:zhaojunfei,项目名称:lemon,代码行数:17,代码来源:MsgInfoController.java

示例5: addStudent

import org.springframework.web.bind.annotation.ModelAttribute; //导入依赖的package包/类
@RequestMapping(value = "/addStudent",method = RequestMethod.POST)
    public String addStudent(@ModelAttribute("student") @Validated Student student, BindingResult bindingResult,ModelMap model){
//        if(bindingResult.hasErrors()){
//            return "addStudent";
//        }
        System.out.println("id = "+student.getId());
        model.addAttribute("id",student.getId());
        model.addAttribute("name",student.getName());
        model.addAttribute("age",student.getAge());
        model.addAttribute("receivePaper",student.isReceivePaper());
        model.addAttribute("gender",student.getGender());
        model.addAttribute("color",student.getColor());
        model.addAttribute("city",student.getCity());
        model.addAttribute("tec",student.getTec());
        return "result";
    }
 
开发者ID:garyhu1,项目名称:spring_mvc_demo,代码行数:17,代码来源:InputController.java

示例6: export

import org.springframework.web.bind.annotation.ModelAttribute; //导入依赖的package包/类
@RequestMapping("train-info-export")
public void export(@ModelAttribute Page page,
        @RequestParam Map<String, Object> parameterMap,
        HttpServletRequest request, HttpServletResponse response)
        throws Exception {
    String tenantId = tenantHolder.getTenantId();
    List<PropertyFilter> propertyFilters = PropertyFilter
            .buildFromMap(parameterMap);
    propertyFilters.add(new PropertyFilter("EQS_tenantId", tenantId));
    page = trainInfoManager.pagedQuery(page, propertyFilters);

    List<TrainInfo> trainInfos = (List<TrainInfo>) page.getResult();

    TableModel tableModel = new TableModel();
    tableModel.setName("train info");
    tableModel.addHeaders("id", "name");
    tableModel.setData(trainInfos);
    exportor.export(request, response, tableModel);
}
 
开发者ID:zhaojunfei,项目名称:lemon,代码行数:20,代码来源:TrainInfoController.java

示例7: save

import org.springframework.web.bind.annotation.ModelAttribute; //导入依赖的package包/类
@RequestMapping("group-info-save")
public String save(@ModelAttribute GroupInfo groupInfo,
        @RequestParam Map<String, Object> parameterMap,
        RedirectAttributes redirectAttributes) {
    String tenantId = tenantHolder.getTenantId();
    GroupInfo dest = null;
    Long id = groupInfo.getId();

    if (id != null) {
        dest = groupInfoManager.get(id);
        beanMapper.copy(groupInfo, dest);
    } else {
        dest = groupInfo;
        dest.setTenantId(tenantId);
    }

    groupInfoManager.save(dest);

    messageHelper.addFlashMessage(redirectAttributes, "core.success.save",
            "保存成功");

    return "redirect:/group/group-info-list.do";
}
 
开发者ID:zhaojunfei,项目名称:lemon,代码行数:24,代码来源:GroupInfoController.java

示例8: logonMethod

import org.springframework.web.bind.annotation.ModelAttribute; //导入依赖的package包/类
@RequestMapping(value = "/logon.sf", method = RequestMethod.POST)
public String logonMethod(
		@ModelAttribute("logon") Logon logon,
		BindingResult result, SessionStatus status) {
	
	logonValidator.validate(logon, result);
	
	if (result.hasErrors()) {
		//if validator failed
		return "login";
	} else {
		status.setComplete();
		//form success
		return "securepage";
	}
}
 
开发者ID:Illusionist80,项目名称:SpringTutorial,代码行数:17,代码来源:AccountsController.java

示例9: export

import org.springframework.web.bind.annotation.ModelAttribute; //导入依赖的package包/类
@RequestMapping("form-template-export")
public void export(@ModelAttribute Page page,
        @RequestParam Map<String, Object> parameterMap,
        HttpServletRequest request, HttpServletResponse response)
        throws Exception {
    String tenantId = tenantHolder.getTenantId();
    List<PropertyFilter> propertyFilters = PropertyFilter
            .buildFromMap(parameterMap);
    propertyFilters.add(new PropertyFilter("EQS_tenantId", tenantId));
    page = formTemplateManager.pagedQuery(page, propertyFilters);

    List<FormTemplate> dynamicModels = (List<FormTemplate>) page
            .getResult();

    TableModel tableModel = new TableModel();
    tableModel.setName("dynamic model");
    tableModel.addHeaders("id", "name");
    tableModel.setData(dynamicModels);
    exportor.export(request, response, tableModel);
}
 
开发者ID:zhaojunfei,项目名称:lemon,代码行数:21,代码来源:FormTemplateController.java

示例10: save

import org.springframework.web.bind.annotation.ModelAttribute; //导入依赖的package包/类
@RequestMapping("contract-info-save")
public String save(@ModelAttribute ContractInfo contractInfo,
        @RequestParam Map<String, Object> parameterMap,
        RedirectAttributes redirectAttributes) {
    String tenantId = tenantHolder.getTenantId();
    ContractInfo dest = null;

    Long id = contractInfo.getId();

    if (id != null) {
        dest = contractInfoManager.get(id);
        beanMapper.copy(contractInfo, dest);
    } else {
        dest = contractInfo;
        dest.setTenantId(tenantId);
    }

    contractInfoManager.save(dest);

    messageHelper.addFlashMessage(redirectAttributes, "core.success.save",
            "保存成功");

    return "redirect:/contract/contract-info-list.do";
}
 
开发者ID:zhaojunfei,项目名称:lemon,代码行数:25,代码来源:ContractInfoController.java

示例11: save

import org.springframework.web.bind.annotation.ModelAttribute; //导入依赖的package包/类
@RequestMapping("bpm-conf-operation-save")
public String save(@ModelAttribute BpmConfOperation bpmConfOperation,
        @RequestParam("bpmConfNodeId") Long bpmConfNodeId) {
    if ((bpmConfOperation.getValue() == null)
            || "".equals(bpmConfOperation.getValue())) {
        return "redirect:/bpm/bpm-conf-operation-list.do?bpmConfNodeId="
                + bpmConfNodeId;
    }

    bpmConfOperation.setBpmConfNode(bpmConfNodeManager.get(bpmConfNodeId));
    bpmConfOperationManager.save(bpmConfOperation);

    BpmConfOperation dest = bpmConfOperation;
    String taskDefinitionKey = dest.getBpmConfNode().getCode();
    String processDefinitionId = dest.getBpmConfNode().getBpmConfBase()
            .getProcessDefinitionId();
    String operation = dest.getValue();
    taskDefinitionConnector.addOperation(taskDefinitionKey,
            processDefinitionId, operation);

    return "redirect:/bpm/bpm-conf-operation-list.do?bpmConfNodeId="
            + bpmConfNodeId;
}
 
开发者ID:zhaojunfei,项目名称:lemon,代码行数:24,代码来源:BpmConfOperationController.java

示例12: export

import org.springframework.web.bind.annotation.ModelAttribute; //导入依赖的package包/类
@RequestMapping("budget-info-export")
public void export(@ModelAttribute Page page,
        @RequestParam Map<String, Object> parameterMap,
        HttpServletRequest request, HttpServletResponse response)
        throws Exception {
    String tenantId = tenantHolder.getTenantId();
    List<PropertyFilter> propertyFilters = PropertyFilter
            .buildFromMap(parameterMap);
    propertyFilters.add(new PropertyFilter("EQS_tenantId", tenantId));
    page = budgetInfoManager.pagedQuery(page, propertyFilters);

    List<BudgetInfo> budgetInfos = (List<BudgetInfo>) page.getResult();

    TableModel tableModel = new TableModel();
    tableModel.setName("budget info");
    tableModel.addHeaders("id", "name");
    tableModel.setData(budgetInfos);
    exportor.export(request, response, tableModel);
}
 
开发者ID:zhaojunfei,项目名称:lemon,代码行数:20,代码来源:BudgetInfoController.java

示例13: submit

import org.springframework.web.bind.annotation.ModelAttribute; //导入依赖的package包/类
/**
 * Maps and handles custom behavior in the Edit page (POST mode)
 * @param message The information that is bound to the HTML form and used to update the database
 * @return Custom message sent to the client - in this case, a redirect
 */
@RequestMapping(value="/edit", method=RequestMethod.POST)
public String submit(@ModelAttribute Message message)
{
    try
    {
        String username = Util.getUsername();
        message.setUsername(username);

        message = encryptMessage(message);
        messageRepository.save(message);

        // TO-DO: redirect and show a success message
        return "redirect:/cpanel.html";
    }
    catch(DataIntegrityViolationException ex) // message is too long for DB field
    {
        return "redirect:/edit?error";
    }
}
 
开发者ID:arturhgca,项目名称:message-crypto,代码行数:25,代码来源:MessageController.java

示例14: save

import org.springframework.web.bind.annotation.ModelAttribute; //导入依赖的package包/类
@RequestMapping("template-field-save")
public String save(@ModelAttribute TemplateField templateField,
        @RequestParam("infoId") Long infoId,
        RedirectAttributes redirectAttributes) {
    String tenantId = tenantHolder.getTenantId();
    Long id = templateField.getId();
    TemplateField dest = null;

    if (id != null) {
        dest = templateFieldManager.get(id);
        beanMapper.copy(templateField, dest);
    } else {
        dest = templateField;
        dest.setTenantId(tenantId);
    }

    dest.setTemplateInfo(templateInfoManager.get(infoId));

    templateFieldManager.save(dest);

    messageHelper.addFlashMessage(redirectAttributes, "core.success.save",
            "保存成功");

    return "redirect:/template/template-field-list.do";
}
 
开发者ID:zhaojunfei,项目名称:lemon,代码行数:26,代码来源:TemplateFieldController.java

示例15: save

import org.springframework.web.bind.annotation.ModelAttribute; //导入依赖的package包/类
@RequestMapping("pim-info-save")
public String save(@ModelAttribute PimInfo pimInfo,
        RedirectAttributes redirectAttributes) {
    String userId = currentUserHolder.getUserId();
    String tenantId = tenantHolder.getTenantId();
    Long id = pimInfo.getId();
    PimInfo dest = null;

    if (id != null) {
        dest = pimInfoManager.get(id);
        beanMapper.copy(pimInfo, dest);
    } else {
        dest = pimInfo;
        dest.setUserId(userId);
        dest.setTenantId(tenantId);
    }

    pimInfoManager.save(dest);
    messageHelper.addFlashMessage(redirectAttributes, "core.success.save",
            "保存成功");

    return "redirect:/pim/pim-info-list.do";
}
 
开发者ID:zhaojunfei,项目名称:lemon,代码行数:24,代码来源:PimInfoController.java


注:本文中的org.springframework.web.bind.annotation.ModelAttribute类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。