zoukankan      html  css  js  c++  java
  • java上传方法

        @Transactional
        public String saveImportPermitZt(String path,SysUser user,String hvalue){
            int index = 0;
            String datamsg="";
            SysFile sysfilee = null;
            String patch = path;
            //截取file/之后的内容 indexs+5-------indexs+0为截取file/的内容(包含file/)
            int indexs = patch.indexOf("file/");
            String newStr = patch.substring(indexs + 5);
            
            String patchs = path;
            int indess = patchs.indexOf("/upload");
            String ing = patchs.substring(indess + 0);
            SysFileMap sysfile = new SysFileMap();
            List<SysFile> errorPermitList  = new ArrayList<SysFile>();
            JsonRootBean JsonRootBean = new JsonRootBean();
            try {
                // 创建输入流
                InputStream stream = new FileInputStream(path);
                    sysfilee = new SysFile();
                        List<Map<String, Object>> list = this.sysDepartmentManager.getEntityDao().findListObjectBySql("sqlY语句",hvalue);
                        String sts = String.valueOf(list.get(0).get("hkey"));
                        sysfilee.setCretime(new Date());
                        sysfilee.setCreusername(user.getUsername());
                        sysfilee.setCreuserid(user.getDepid());
                        sysfilee.setFilename(newStr);
                        sysfilee.setFilepath(newStr);
                        sysfilee.setPicpath(ing);
                            sysFileDao.save(sysfilee);
                            sysfile.setFileid(sysfilee.getFileid());
                            sysfile.setTabletype(sts);
                            sysFileMapDao.save(sysfile);
                            index++;
            } catch (Exception e) {
                e.printStackTrace();
                JsonRootBean.setTipmsg("读取文件失败");
                return JSONUtil.beanToJson(JsonRootBean);
            }
            return JSONUtil.beanToJson(JsonRootBean);
        }
  • 相关阅读:
    Java 实例
    为什么很多程序员工作时都戴耳机?
    HTTP状态码大全
    Eclipse怎么切换工作空间
    maven POM.xml内的标签大全详解
    利用html5的FormData对象实现多图上传
    后台定时器注解方式
    js多定时器
    解决ios上微信无法捕获返回键按钮事件的问题
    上传文件,获取表单数据和文件流
  • 原文地址:https://www.cnblogs.com/yanchaohui/p/11579529.html
Copyright © 2011-2022 走看看