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.</
  • 0
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值