上传下载加分页
来源:互联网 发布:微软雅黑bold for mac 编辑:程序博客网 时间:2024/06/06 13:02
上传下载public String update(House house, MultipartFile multipartFile, HttpServletRequest request) throws IOException { String filename = multipartFile.getOriginalFilename(); //获取新的文件名 long millis = System.currentTimeMillis(); String newName = millis+filename; //获取文件流 InputStream inputStream1 = multipartFile.getInputStream(); //获取物理路径D:\ideal work\aa\web String wlPath = "D:\\ideal work\\fourDemo\\web\\images\\"+newName; String ljPath = "../images/"+newName; String pathRoot = request.getSession().getServletContext().getRealPath("/");//自动寻找target根目录 String lsPath = pathRoot+"\\images\\"+newName; File wlFile = new File("D:\\ideal work\\fourDemo\\web\\images"); File lsFile = new File(pathRoot+"\\images\\"); if(!wlFile.exists()) { wlFile.mkdir(); } if(!lsFile.exists()) { lsFile.mkdir(); } if(!multipartFile.isEmpty()) { //将文件放入物理路径 FileOutputStream wlFileOutputStream = new FileOutputStream(wlPath); //将文件放入临时路径 FileOutputStream lsFileOutputStream1 =new FileOutputStream(lsPath); int line = 0; while ((line = inputStream1.read()) != -1) { //写入物理路径 wlFileOutputStream.write(line); //写入临时路径 lsFileOutputStream1.write(line); } wlFileOutputStream.flush(); lsFileOutputStream1.flush(); lsFileOutputStream1.close(); wlFileOutputStream.close(); inputStream1.close(); } house.setHimg(ljPath); service.update(house); return "redirect:/house/show";}分页public String show(HttpServletRequest request,Integer id,String pageNo, String pageSize){ int num = 1; int size = 3; if(pageNo != null && !"".equals(pageNo)) { num = Integer.parseInt(pageNo); } if (pageSize != null && !"".equals(pageSize)) { size = Integer.parseInt(pageSize); } PageHelper.startPage(num,size); //查询数据库信息 List<House> all = service.findAll(id); //将信息放入PageInfo进行分页 PageInfo<House> pageInfo = new PageInfo<House>(all); request.setAttribute("pageHelper",pageInfo); return "show";}Jsp_______________________________共<span>${pageHelper.total}条记录当前显示</span><span>现在显示第${pageHelper.pageNum}页</span><a href="/house/show?pageNo=${pageHelper.firstPage}&pageSize=${pageHelper.pageSize}" >首页</a> <c:if test="${pageHelper.isFirstPage == true}"> <a href="/house/show?pageNo=${pageHelper.firstPage}&pageSize=${pageHelper.pageSize}" >上一页</a> </c:if> <c:if test="${pageHelper.isFirstPage != true}"> <a href="/house/show?pageNo=${pageHelper.prePage}&pageSize=${pageHelper.pageSize}">上一页</a> </c:if><c:if test="${pageHelper.isLastPage == true}"> <a href="/house/show?pageNo=${pageHelper.lastPage}&pageSize=${pageHelper.pageSize}">下一页</a></c:if><c:if test="${pageHelper.isLastPage != true}"> <a href="/house/show?pageNo=${pageHelper.nextPage}&pageSize=${pageHelper.pageSize}">下一页</a></c:if><a href="/house/show?pageNo=${pageHelper.lastPage}&pageSize=${pageHelper.pageSize}">尾页</a>$("#btn").click(function () { var arr=$(":checked"); var ids=[]; $.each(arr, function() { if(this.value>0){ if(this.checked){ ids.push($(this).val()); } } }); if(ids.length==0){ alert("最少选中一个"); } //location.href="/house/del?ids="+ids.join(",");});$("#dian").click(function(){ var arr=$("[type=checkbox]"); if(this.checked){ $.each(arr, function() { this.checked=true; }); }else{ $.each(arr, function() { this.checked=false; }); }});
阅读全文
1 0
- 上传下载加分页
- Repeater加js分页
- 分页加union all
- 学习datalist加分页
- 表单加分页功能
- mybatis加mysql分页
- 生成静态页加分页
- datalist 分页加自动编号
- Rails 列表加分页功能
- 不加插件的分页
- ajax模糊查询加分页
- 导航条加按钮分页
- 分页设计(加搜索)
- 上传下载
- 上传下载
- 上传下载
- 上传下载
- 上传下载
- Java多线程编程-(12)-Java中的队列同步器AQS和ReentrantLock锁原理简要分析
- 开启我的Java之旅(不甘心再做一个小白)
- 二进制枚举子集
- 双十一还没到,EasyRecovery降价风暴已来到!
- java 泛型之 通配符的限定 之 super 的实例
- 上传下载加分页
- 真正的原生js写的拖拽来了
- 参考教程地址
- i++与++i是一样的吗?
- 软件工程作业--03 黄金点游戏
- Java发展史
- uva170
- 解决symbol(s) not found for architecture x86_64报错
- centos 6.8 下python2.6 升级python2.7,安装pip工具