在我的 Spring Web 应用程序中:
@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;
}
}
减少/绑定参数总数的可能方法是什么。