List of usage examples for org.springframework.validation BindingResult getSuppressedFields
default String[] getSuppressedFields()
From source file:com.mum.controller.ProductController.java
@RequestMapping(value = "products/add", method = RequestMethod.POST) public String processAddNewProductForm(@ModelAttribute("newProduct") Product product, BindingResult result, HttpServletRequest request, HttpServletResponse response) { MultipartFile productImage = product.getProductImage(); String rootDirectory = request.getSession().getServletContext().getRealPath("/../../../"); if (productImage != null && !productImage.isEmpty()) { try {/*from ww w .ja v a 2 s . c o m*/ productImage.transferTo( new File(rootDirectory + "\\images\\" + productImage.getOriginalFilename() + ".png")); } catch (Exception e) { throw new RuntimeException("Product Image saving failed", e); } } String[] suppressedFields = result.getSuppressedFields(); if (suppressedFields.length > 0) { throw new RuntimeException("Attempting to bind disallowed fields:" + StringUtils.arrayToCommaDelimitedString(suppressedFields)); } productService.addProduct(product); //return "redirect:/products/add"; //return "redirect:/products"; return ""; }