一、返回
返回上一级
<button type="button" onclick="window.history.back();" class="btn btn-danger">取 消</button>
2. 返回上一级菜单
<a class="btn btn-danger" href="initPlaceOrder"> 取 消</a>
二、验证为空,错误框变红(配置了Validation的基础上)--以editPlaceOrder为例
1. 添加common.css
.error { background-color: red; }
2. ValidationMessage中添加不合要求时要显示的提示信息
errors.required={field}为必须输入项目 errors.email=email格式不正确 errors.qq=qq格式不正确 errors.zip=zip必须为数字格式 errors.length=zip长度必须为六位 errors.mobile=手机输入格式不正确 errors.date=日期格式不正确
3. PlaceOrderForm中添加判断,如
@NotEmpty(field="客户单位", message="{errors.required}") private String guestCompany;
4. editPlaceOrder.jsp中添加css连接,css显示格式
<link href="css/common.css" rel="stylesheet"> <td style="background-color: #f9f9f9;">客户单位</td> <td><form:input path="guestCompany" cssClass="form-control" cssErrorClass="form-control error" value="${placeOrderForm.guestCompany}" /></td>
5. PlaceOrderController.java中添加判断,用于显示错误
if(results.hasErrors()) { log.info("修改销售订单信息"); List<Item> provinceList = itemListComponent.getProvinceList(); model.addAttribute("provinceList", provinceList); List<Item> cityList = itemListComponent.getCityList(placeOrderForm.getProvinceId()); model.addAttribute("cityList", cityList); List<Item> expressList = itemListComponent.getExpressList(); model.addAttribute("expressList", expressList); model.addAttribute("placeOrderForm", placeOrderForm); return "manager/placeOrder/editPlaceOrder"; }
其代码类似initEditPlaceOrder(修改销售订单信息初始化)
@RequestMapping(value = "initEditPlaceOrder", method = RequestMethod.GET) public String initEditPlaceOrder(Model model, PlaceOrderForm placeOrderForm) { log.info("修改销售订单信息初始化"); PlaceOrderForm result = placeOrderService.searchPlaceOrder(placeOrderForm); model.addAttribute("placeOrderForm", result); List<Item> provinceList = itemListComponent.getProvinceList(); List<Item> cityList = itemListComponent.getCityList(result.getProvinceId()); model.addAttribute("provinceList", provinceList); model.addAttribute("cityList", cityList); List<Item> expressList = itemListComponent.getExpressList(); model.addAttribute("expressList", expressList); return "manager/placeOrder/editPlaceOrder"; }
注意:cityList的备选项需依据provinceList,provinceList需遍历数据库
List<Item> cityList = itemListComponent.getCityList(placeOrderForm.getProvinceId()); model.addAttribute("cityList", cityList);