请问老师4-13我的程序走到Shop shop=null,后边shop就是null了,try完了就停了,不往下走了
@RequestMapping(value = “/regitershop”,method = RequestMethod.POST)
@ResponseBody
private Map<String,Object>registersShop(HttpServletRequest request) {
Map<String ,Object>modleMap=new HashMap<>();
if (!CodeUtil.changeVerifyCode(request)){
modleMap.put("success",false);
modleMap.put("errMsg","验证码错误");
return modleMap;
}
//接收并转化相应的参数,包括店铺信息以及图片信息
String shopStr= HttpServletRequstUtil.getString(request,"shopStr");
ObjectMapper objectMapper=new ObjectMapper();
Shop shop;
try{
shop=objectMapper.readValue(shopStr,Shop.class);
}catch (Exception e){
modleMap.put("success",false);
modleMap.put("errMsg",e.getMessage());
return modleMap;
}
CommonsMultipartFile shopImg;
CommonsMultipartResolver commonsMultipartResolver=new CommonsMultipartResolver(
request.getSession().getServletContext()
);
if (commonsMultipartResolver.isMultipart(request)){
MultipartHttpServletRequest multipartHttpServletRequest= (MultipartHttpServletRequest) request;
shopImg= (CommonsMultipartFile) multipartHttpServletRequest.getFile("shopImg");
}else{
modleMap.put("success",false);
modleMap.put("errMsg","上传图片不能为空");
return modleMap;
}
SSM商铺V1.0,解决毕设痛点;SpringBoot商铺V2.0,满足工作刚需
了解课程