當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。