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


Java BindingResult.getAllErrors方法代码示例

本文整理汇总了Java中org.springframework.validation.BindingResult.getAllErrors方法的典型用法代码示例。如果您正苦于以下问题:Java BindingResult.getAllErrors方法的具体用法?Java BindingResult.getAllErrors怎么用?Java BindingResult.getAllErrors使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.validation.BindingResult的用法示例。


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

示例1: saveMedic

import org.springframework.validation.BindingResult; //导入方法依赖的package包/类
@PostMapping
public ResponseEntity<?> saveMedic(@RequestBody Medic medic, BindingResult result) {
	medicValidator.validate(medic, result);

	if (result.hasErrors()) {
		return new ResponseEntity<>(result.getAllErrors(), HttpStatus.NOT_ACCEPTABLE);
	}
	
	Medic newMedic = medicService.save(medic);

	if (newMedic != null) {
		final URI location = ServletUriComponentsBuilder.fromCurrentServletMapping().path("/v1/medics/{id}").build()
				.expand(newMedic.getId()).toUri();

		final HttpHeaders headers = new HttpHeaders();
		headers.setLocation(location);

		return new ResponseEntity<Void>(headers, HttpStatus.CREATED);
	}

	return new ResponseEntity<Void>(HttpStatus.SERVICE_UNAVAILABLE);
}
 
开发者ID:JUGIstanbul,项目名称:second-opinion-api,代码行数:23,代码来源:MedicController.java

示例2: add

import org.springframework.validation.BindingResult; //导入方法依赖的package包/类
@RequestMapping(method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "新增任务信息", notes = "向系统中添加新的任务,任务必须是存储过程,shell脚本,cmd脚本,可执行jar包,二进制文件中的一种")
public String add(@Validated TaskDefineEntity taskDefineEntity, BindingResult bindingResult, HttpServletResponse response, HttpServletRequest request) {
    // 校验参数信息
    if (bindingResult.hasErrors()) {
        for (ObjectError m : bindingResult.getAllErrors()) {
            response.setStatus(421);
            return Hret.error(421, m.getDefaultMessage(), null);
        }
    }

    RetMsg retMsg = taskDefineService.add(parse(request));
    if (retMsg.checkCode()) {
        return Hret.success(retMsg);
    }
    response.setStatus(retMsg.getCode());
    return Hret.error(retMsg);
}
 
开发者ID:hzwy23,项目名称:batch-scheduler,代码行数:20,代码来源:TaskDefineController.java

示例3: add

import org.springframework.validation.BindingResult; //导入方法依赖的package包/类
/**
 * 新增域
 */
@RequestMapping(method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "新增域信息", notes = "添加新的域信息,新增的域默认授权给创建人")
@ApiImplicitParam(name = "domain_id", value = "域编码", required = true, dataType = "String")
public String add(@Validated DomainEntity domainEntity, BindingResult bindingResult, HttpServletResponse response, HttpServletRequest request) {
    if (bindingResult.hasErrors()) {
        for (ObjectError m : bindingResult.getAllErrors()) {
            response.setStatus(421);
            return Hret.error(421, m.getDefaultMessage(), null);
        }
    }

    String userId = JwtService.getConnUser(request).getUserId();
    domainEntity.setDomainModifyUser(userId);
    domainEntity.setCreateUserId(userId);
    RetMsg retMsg = domainService.add(domainEntity);

    if (retMsg.checkCode()) {
        return Hret.success(retMsg);
    }

    response.setStatus(retMsg.getCode());
    return Hret.error(retMsg);
}
 
开发者ID:hzwy23,项目名称:batch-scheduler,代码行数:28,代码来源:DomainController.java

示例4: update

import org.springframework.validation.BindingResult; //导入方法依赖的package包/类
@RequestMapping(method = RequestMethod.PUT)
@ResponseBody
public String update(@Validated TaskDefineEntity taskDefineEntity, BindingResult bindingResult, HttpServletResponse response, HttpServletRequest request) {
    if (bindingResult.hasErrors()) {
        for (ObjectError m : bindingResult.getAllErrors()) {
            response.setStatus(421);
            return Hret.error(421, m.getDefaultMessage(), null);
        }
    }

    RetMsg retMsg = taskDefineService.update(parse(request));
    if (!retMsg.checkCode()) {
        response.setStatus(retMsg.getCode());
        return Hret.error(retMsg);
    }
    return Hret.success(retMsg);
}
 
开发者ID:hzwy23,项目名称:batch-scheduler,代码行数:18,代码来源:TaskDefineController.java

示例5: createCategory

import org.springframework.validation.BindingResult; //导入方法依赖的package包/类
@RequestMapping(value = "/category/create", method = RequestMethod.POST)
public String createCategory(@Valid @ModelAttribute CategoryDTO categoryDTO, BindingResult br, RedirectAttributes attr){
    if(br.hasErrors()){
        StringBuilder errorMsg = new StringBuilder();
        for(ObjectError i : br.getAllErrors()){
            errorMsg.append(i.getDefaultMessage());
        }
        attr.addFlashAttribute("error", errorMsg.toString());
        return "redirect:/error";
    }

    Category category = new Category();
    category.setCategoryName(categoryDTO.getCategoryNew());
    try{
        categoryService.saveCategory(category);
        categoryService.uploadCategoryStarterFiles(categoryDTO.getCategoryNew());
    }catch (Exception e){
        attr.addFlashAttribute("error", "Could not create category. Please contact our support team.");
        return "redirect:/error";
    }

    attr.addFlashAttribute("categoryDTO", categoryDTO);
    return "redirect:/admin";

}
 
开发者ID:Exercon,项目名称:AntiSocial-Platform,代码行数:26,代码来源:AdminController.java

示例6: createCategory

import org.springframework.validation.BindingResult; //导入方法依赖的package包/类
@RequestMapping(value = "/category/create", method = RequestMethod.POST)
public String createCategory(@Valid @ModelAttribute CategoryDTO categoryDTO, BindingResult br, RedirectAttributes attr){
    if(br.hasErrors()){
        StringBuilder errorMsg = new StringBuilder();
        for(ObjectError i : br.getAllErrors()){
            errorMsg.append(i.getDefaultMessage());
        }
        attr.addFlashAttribute("error", errorMsg.toString());
        return "redirect:/oups";
    }

    Category category = new Category();
    category.setCategoryName(categoryDTO.getCategoryNew());
    try{
        categoryService.saveCategory(category);
        categoryService.uploadCategoryStarterFiles(categoryDTO.getCategoryNew());
    }catch (Exception e){
        attr.addFlashAttribute("error", "Could not create category. Please contact our support team.");
        return "redirect:/oups";
    }

    attr.addFlashAttribute("categoryDTO", categoryDTO);
    return "redirect:/admin";

}
 
开发者ID:Exercon,项目名称:AntiSocial-Platform,代码行数:26,代码来源:AdminController.java

示例7: sendSignatureParameters

import org.springframework.validation.BindingResult; //导入方法依赖的package包/类
@RequestMapping(method = RequestMethod.POST)
public String sendSignatureParameters(Model model, HttpServletRequest response,
		@ModelAttribute("signatureMultipleDocumentsForm") @Valid SignatureMultipleDocumentsForm signatureMultipleDocumentsForm, BindingResult result) {
	if (result.hasErrors()) {
		for (ObjectError error : result.getAllErrors()) {
			logger.error(error.getDefaultMessage());
		}
		return SIGNATURE_PARAMETERS;
	}
	model.addAttribute("signatureMultipleDocumentsForm", signatureMultipleDocumentsForm);
	model.addAttribute("digestAlgorithm", signatureMultipleDocumentsForm.getDigestAlgorithm());
	model.addAttribute("rootUrl", "sign-multiple-documents");
	model.addAttribute("nexuUrl", nexuUrl);
	return SIGNATURE_PROCESS;
}
 
开发者ID:esig,项目名称:dss-demonstrations,代码行数:16,代码来源:SignatureMultipleDocumentsController.java

示例8: sendSignatureParameters

import org.springframework.validation.BindingResult; //导入方法依赖的package包/类
@RequestMapping(method = RequestMethod.POST)
public String sendSignatureParameters(Model model, HttpServletRequest response,
		@ModelAttribute("signatureDocumentForm") @Valid SignatureDocumentForm signatureDocumentForm, BindingResult result) {
	if (result.hasErrors()) {
		for (ObjectError error : result.getAllErrors()) {
			logger.error(error.getDefaultMessage());
		}
		return SIGNATURE_PARAMETERS;
	}
	model.addAttribute("signatureDocumentForm", signatureDocumentForm);
	model.addAttribute("digestAlgorithm", signatureDocumentForm.getDigestAlgorithm());
	model.addAttribute("rootUrl", "sign-a-document");
	model.addAttribute("nexuUrl", nexuUrl);
	return SIGNATURE_PROCESS;
}
 
开发者ID:esig,项目名称:dss-demonstrations,代码行数:16,代码来源:SignatureController.java

示例9: handleBindException

import org.springframework.validation.BindingResult; //导入方法依赖的package包/类
@Override
protected ResponseEntity<Object> handleBindException(BindException exception,
                                                     HttpHeaders headers,
                                                     HttpStatus status,
                                                     WebRequest request) {
    logger.error(CLIENT_ERROR, exception);
    final BindingResult bindingResult = exception.getBindingResult();
    final GenericResponse bodyOfResponse = new GenericResponse(bindingResult.getAllErrors(),
            "Invalid" + bindingResult.getObjectName());
    return handleExceptionInternal(exception, bodyOfResponse, new HttpHeaders(), HttpStatus.BAD_REQUEST, request);
}
 
开发者ID:sweIhm,项目名称:sweiproject-tg2b-1,代码行数:12,代码来源:ExceptionController.java

示例10: handleMethodArgumentNotValid

import org.springframework.validation.BindingResult; //导入方法依赖的package包/类
@Override
protected ResponseEntity<Object> handleMethodArgumentNotValid(MethodArgumentNotValidException exception,
                                                              HttpHeaders headers,
                                                              HttpStatus status,
                                                              WebRequest request) {
    logger.error(CLIENT_ERROR, exception);
    final BindingResult bindingResult = exception.getBindingResult();
    final GenericResponse bodyOfResponse = new GenericResponse(bindingResult.getAllErrors(),
            "Invalid" + bindingResult.getObjectName());
    return handleExceptionInternal(exception, bodyOfResponse, new HttpHeaders(), HttpStatus.BAD_REQUEST, request);
}
 
开发者ID:sweIhm,项目名称:sweiproject-tg2b-1,代码行数:12,代码来源:ExceptionController.java

示例11: create

import org.springframework.validation.BindingResult; //导入方法依赖的package包/类
@PostMapping(params = "form")
public ModelAndView create(@Valid Item item,BindingResult result,RedirectAttributes redirect) {
	if (result.hasErrors()) { return new ModelAndView(ITEM_URI + "form","formErrors",result.getAllErrors()); }
	item = this.itemRepository.save(item);
	redirect.addFlashAttribute("globalMessage","Item gravado com sucesso");
	return new ModelAndView("redirect:/" + ITEM_URI + "{item.id}","item.id",item.getId());
}
 
开发者ID:boaglio,项目名称:spring-boot-greendogdelivery-casadocodigo,代码行数:8,代码来源:ItemController.java

示例12: create

import org.springframework.validation.BindingResult; //导入方法依赖的package包/类
@PostMapping(params = "form")
public ModelAndView create(@Valid Cliente cliente,BindingResult result,RedirectAttributes redirect) {
	if (result.hasErrors()) { return new ModelAndView(CLIENTE_URI + "form","formErrors",result.getAllErrors()); }
	cliente = this.clienteRepository.save(cliente);
	redirect.addFlashAttribute("globalMessage","Cliente gravado com sucesso");
	return new ModelAndView("redirect:/" + CLIENTE_URI + "{cliente.id}","cliente.id",cliente.getId());
}
 
开发者ID:boaglio,项目名称:spring-boot-greendogdelivery-casadocodigo,代码行数:8,代码来源:ClienteController.java

示例13: FormErrorMap

import org.springframework.validation.BindingResult; //导入方法依赖的package包/类
public FormErrorMap(BindingResult result) {
    this.errors = result.getAllErrors();
    this.messages = new HashMap<>();

    for (ObjectError error : errors) {
        FieldError fe = (FieldError) error;
        setMessage(fe.getField(), error.getDefaultMessage());
    }
}
 
开发者ID:remipassmoilesel,项目名称:simple-hostel-management,代码行数:10,代码来源:FormErrorMap.java

示例14: update

import org.springframework.validation.BindingResult; //导入方法依赖的package包/类
/**
 * 更新域信息
 */
@RequestMapping(method = RequestMethod.PUT)
@ResponseBody
@ApiOperation(value = "更新域定义信息", notes = "更新域的详细信息,如:域名称,域状态")
@ApiImplicitParams({
        @ApiImplicitParam(required = true, name = "domain_id", value = "域编码"),
        @ApiImplicitParam(required = true, name = "domain_desc", value = "域描述信息")
})
public String update(@Validated DomainEntity domainEntity, BindingResult bindingResult, HttpServletResponse response, HttpServletRequest request) {
    if (bindingResult.hasErrors()) {
        for (ObjectError m : bindingResult.getAllErrors()) {
            response.setStatus(421);
            return Hret.error(421, m.getDefaultMessage(), null);
        }
    }

    String userId = JwtService.getConnUser(request).getUserId();
    domainEntity.setDomainModifyUser(userId);
    domainEntity.setCreateUserId(userId);

    Boolean status = authService.domainAuth(request, domainEntity.getDomainId(), "w").getStatus();
    if (!status) {
        response.setStatus(403);
        return Hret.error(403, "你没有权限编辑域 [ " + domainEntity.getDomainDesc() + " ]", domainEntity);
    }

    RetMsg retMsg = domainService.update(domainEntity);
    if (retMsg.checkCode()) {
        return Hret.success(retMsg);
    }

    response.setStatus(retMsg.getCode());
    return Hret.error(retMsg);
}
 
开发者ID:hzwy23,项目名称:batch-scheduler,代码行数:37,代码来源:DomainController.java

示例15: updateCategory

import org.springframework.validation.BindingResult; //导入方法依赖的package包/类
@RequestMapping(value = "/category/update", method = RequestMethod.POST)
public String updateCategory(@Valid @ModelAttribute CategoryDTO categoryDTO, BindingResult br, RedirectAttributes attr){
    if(br.hasErrors()){
        StringBuilder errorMsg = new StringBuilder();
        for(ObjectError i : br.getAllErrors()){
            errorMsg.append(i.getDefaultMessage());
        }
        attr.addFlashAttribute("error", errorMsg.toString());
        return "redirect:/error";
    }
    Category category = categoryService.getCategoryByName(categoryDTO.getCategoryName());
    if(category == null){
        attr.addFlashAttribute("error", "Category not found with this name : "+ categoryDTO.getCategoryName());
        return "redirect:/error";
    }
    category.setCategoryName(categoryDTO.getCategoryNew());
    try{
        categoryService.saveCategory(category);
    }catch (Exception e){
        attr.addFlashAttribute("error", "Could not update category. Please contact our support team.");
        return "redirect:/error";
    }

    attr.addFlashAttribute("categoryDTO", categoryDTO);
    return "redirect:/admin";

}
 
开发者ID:Exercon,项目名称:AntiSocial-Platform,代码行数:28,代码来源:AdminController.java


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