Written [{msg=系统内部错误------3, success=false}] as "application/json" using [org.springframework.http.converter.json.MappingJackson2HttpMessageConverter@52933fa2]
```这是报错的
```下面时更新店铺的代码
@RequestMapping(value="/updateshop",method=RequestMethod.POST)
@ResponseBody
private Map<String, Object> updateShop(HttpServletRequest request) {
Map<String,Object> map=new HashMap<String, Object>();
if(!KaptchaUtil.determineKaptcha(request)) {
map.put("success",false);
map.put("msg","你输入的验证码错误!");
return map;
}
//利用jackson-databind组件完成相应参数转化,图片和店铺信息
String shopStr = HttpServletRequestUtil.getString(request,"shop");
ObjectMapper mapper=new ObjectMapper();
Shop shop=new Shop();
try {
shop = mapper.readValue(shopStr, Shop.class);
} catch (Exception e) {
map.put("success",false);
map.put("msg",e.getMessage()+"------1");
return map;
}
CommonsMultipartFile shopImg=null;
//获取 文件上传内容CommonsMultipartResolver
CommonsMultipartResolver commonsMultipartResolver=new CommonsMultipartResolver(
request.getSession().getServletContext());
if(commonsMultipartResolver.isMultipart(request)) {//判断request里面有没有要上传的文件流
MultipartHttpServletRequest multipartHttpServletRequest=(MultipartHttpServletRequest)request;
shopImg=(CommonsMultipartFile)multipartHttpServletRequest.getFile("shopImg");
}else {
map.put("success",false);
map.put("msg","上传文件过程中出现错误!");
return map;
}
//修改店铺信息
if(shop!=null&&shop.getShopId()!=null) {
ImageHolder thumbnail=new ImageHolder();
ShopExecution se;
try {
if(shopImg==null) {
se=shopService.updateShop(shop,null);
}else {
thumbnail.setImage(shopImg.getInputStream());
thumbnail.setImageName(shopImg.getOriginalFilename().toString());
se=shopService.updateShop(shop,thumbnail);
}
if(se.getState()==ShopStateEnum.SUCCESS.getState()) {
map.put("success",true);
}else {
map.put("success",false);
map.put("msg",se.getStateInfo()+"------3");
return map;
}
} catch (IOException e) {
map.put("success",false);
map.put("msg","文件错误!");
return map;
}
}else {
map.put("success",false);
map.put("msg","请输入商铺注册信息!");
return map;
}
return map;
}
SSM商铺V1.0,解决毕设痛点;SpringBoot商铺V2.0,满足工作刚需
了解课程