使用入门

1、拼接项目路径

<a href="${pageContext.request.contextPath}/sell/seller/order/list"

2、使用案例

  • 表单验证
  • 业务逻辑
  • 数据展示
//2、点击提交
    @PostMapping("/update_submit")
    //将前端submit提交的数据存到@Valid ProductForm form里面.
    public ModelAndView save(@Valid ProductForm form,
                             BindingResult bindingResult,
                             Map<String,Object> map){
        if (bindingResult.hasErrors()){
//            System.out.println("1");
            map.put("msg", bindingResult.getFieldError().getDefaultMessage());
            map.put("url", "/sell/seller/product/update?productId="+form.getProductId());
            return new ModelAndView("common/error",map);
        }

        try {
            //将表单修改的字段放于此处进行修改
            productInfoService.update(form);
        } catch (Exception e) {
//            System.out.println("2");
            map.put("msg", e.getMessage());
            map.put("url", "/sell/seller/product/update?productId="+form.getProductId());
            return new ModelAndView("common/error",map);
        }
        map.put("url", "/sell/seller/product/list");
        return new ModelAndView("common/success",map);
    }
发布了252 篇原创文章 · 获赞 5 · 访问量 7808

猜你喜欢

转载自blog.csdn.net/qq_32603969/article/details/103910804