7.31

1.在validation验证时,controller中的

public String addCommodityType(Model model, HttpSession session, @Valid @ModelAttribute("commodityTypeForm") CommodityTypeForm commodityTypeForm, BindingResult results) throws SQLException, IOException {

要和前台中的form:form标签中的modelAttribute="commodityTypeForm"的名字一样//红色中的commodityTypeForm保持一样。

2.验证非主键的内容不能唯一:以name为例数据库中ID为主键,以name为条件检索数据库中的name,如果为null则可以进行正确操作,如果不为null则提示错误信息

你可能感兴趣的:(7.31)