//告警图片保存路径 public String getPath(){ String path = Thread.currentThread().getContextClassLoader().getResource("").getPath(); try { path=URLDecoder.decode(path,"utf-8"); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } int end = path.length() - "WEB-INF/classes/".length(); path = path.substring(1, end).replace(\'/\', \'\\\'); System.out.print(path); return path; } private String path=getPath()+"image\\"; /** * 对前端传来的base64图片进行解码并保存到image目录 * @param image base64编码图片 * @param notitle * @return imgpath 图片:xxx.png */ //对前端传来的base64图片进行解码 public String decodeBase64ToImage(String alert_pic,String alert_note) { BASE64Decoder decoder = new BASE64Decoder(); String imgPath=alert_note+".png"; try { FileOutputStream write = new FileOutputStream(new File(path+imgPath)); byte[] decoderBytes = decoder.decodeBuffer(alert_pic); write.write(decoderBytes); write.close(); } catch (IOException e) { e.printStackTrace(); } return imgPath; }