1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > SSM框架下实现多图片上传

SSM框架下实现多图片上传

时间:2020-08-23 03:00:00

相关推荐

SSM框架下实现多图片上传

最近在实现一个身份证件多图片上传的功能,那么我们如何基于SSM框架来实现身份证件多图片上传的功能的?下面我们来实现一下。

Controller层:

@RequestMapping("identityAuthentication.do")public void identityAuthentication(HttpServletRequest req, HttpServletResponse resp,Tbcustomer tbcustomer,@RequestParam(value = "picture", required = true) MultipartFile[] myFile)throws ServletException, IOException {resp.setContentType("text/json");try {int CustomerID = Integer.parseInt(req.getSession().getAttribute("customerID").toString());SimpleDateFormat SDF=new SimpleDateFormat("yyyy-MM-dd HH:mm::ss");//时间格式String uploadPath = req.getServletContext().getRealPath("/")+ "\\Temp";int Record = 0;List<String> imageName = new ArrayList<String>();tbcustomer.setCustomerid(CustomerID);//日志新增Tblog tblog=new Tblog();tblog.setCustomerid(CustomerID);tblog.setOperationbehavior("个人中心(身份认证)");try {tblog.setOperationdate(SDF.parse(SDF.format(System.currentTimeMillis())));//日期} catch (ParseException e1) {e1.printStackTrace();}if (myFile.length >= 2) {try {if (myFile != null && myFile.length > 0) {String uploadFileName = "";for (MultipartFile multipartFile : myFile) {uploadFileName = ReadFileUtil.readWriteFile(multipartFile.getInputStream(),multipartFile.getOriginalFilename(),uploadPath);imageName.add(uploadFileName);}if (imageName.size() >= 2) {tbcustomer.setFrontofdocument(imageName.get(0));tbcustomer.setBackofdocument(imageName.get(1));}} } catch (Exception e) {e.</

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。