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);
        }
  • 相关阅读:
    个性化推荐系统中的BadCase分析
    Hadoop优先级调度
    【剑指offer】斐波那契数列
    【剑指offer】旋转数组的最小数字
    【剑指offer】用两个栈实现队列
    【剑指offer】重建二叉树
    【剑指offer】从尾到头打印链表
    【剑指offer】替换空格
    【剑指offer】二维数组中的查找
    聚类算法项目整理
  • 原文地址:https://www.cnblogs.com/yanchaohui/p/11579529.html
Copyright © 2011-2022 走看看