In my Spring web application:
@RequestMapping(value = NEW) public String addProduct(@RequestParam String name, @RequestParam(required = false) String description, @RequestParam String price, @RequestParam String company, ModelMap model, @RequestParam(required = false) String volume, @RequestParam(required = false) String weight) { try { productManagementService.addNewProduct(name, description, company, price, volume, weight); model.addAttribute("confirm", PRODUCT_ADDED); return FORM_PAGE; } catch (NumberFormatException e) { logger.log(Level.SEVERE, INVALID_VALUE); model.addAttribute("error", INVALID_VALUE); return FORM_PAGE; } catch (InvalidUserInputException e) { logger.log(Level.SEVERE, e.getMessage()); model.addAttribute("error", e.getMessage()); return FORM_PAGE; } }
What are the possible ways to reduce / link the total number of arguments.
source share