ssm项目,运行后本地jquery文件找不到,而其他js文件却可以找到(解决)

问题

在这里插入图片描述

如图是我引入的文件

在这里插入图片描述

解决方法

把目录名称修改一下,比如我修改为jquery就解决了问题!!很神奇
在这里插入图片描述

最后记得修改你的路径为新名称

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
前端代码: ``` // 分页展示Hdfs文件列表 function listFiles(pageNum) { $.ajax({ url: "/hdfs/list", type: "GET", dataType: "json", data: {"pageNum": pageNum}, success: function (result) { var data = result.data; var html = ""; $.each(data.list, function (index, item) { var isDir = item.isDir ? "文件夹" : "文件"; var size = item.isDir ? "-" : (item.size / 1024).toFixed(2) + "KB"; html += "<tr><td>" + item.pathSuffix + "</td><td>" + isDir + "</td><td>" + size + "</td><td>" + item.owner + "</td><td>" + item.group + "</td><td>" + item.permission + "</td><td>" + item.modificationTime + "</td><td><button class='btn btn-primary' onclick='downloadFile(\"" + item.path + "\")'>下载</button>" + "<button class='btn btn-danger' onclick='deleteFile(\"" + item.path + "\")'>删除</button></td></tr>"; }); $("#file_list").html(html); $("#page_info").html("第 " + data.pageNum + " 页,共 " + data.pages + " 页,总 " + data.total + " 条记录"); $("#page_nav").html("<ul class='pagination'><li><a href='#' onclick='listFiles(1)'>首页</a></li>" + "<li><a href='#' onclick='listFiles(" + data.prePage + ")'>上一页</a></li>" + "<li><a href='#' onclick='listFiles(" + data.nextPage + ")'>下一页</a></li>" + "<li><a href='#' onclick='listFiles(" + data.pages + ")'>末页</a></li></ul>"); } }); } // 上传文件 function uploadFile() { var formData = new FormData(); formData.append("file", $("#file")[0].files[0]); $.ajax({ url: "/hdfs/upload", type: "POST", data: formData, processData: false, contentType: false, cache: false, success: function (result) { if (result.code == 200) { alert("上传成功"); listFiles(1); } else { alert(result.msg); } } }); } // 删除文件 function deleteFile(path) { if (confirm("您确认要删除该文件吗?")) { $.ajax({ url: "/hdfs/delete", type: "POST", dataType: "json", data: {"path": path}, success: function (result) { if (result.code == 200) { alert("删除成功"); listFiles(1); } else { alert(result.msg); } } }); } } // 下载文件 function downloadFile(path) { window.location.href = "/hdfs/download?path=" + path; } ``` 后端代码: ``` // 分页展示Hdfs文件列表 @GetMapping("/list") @ResponseBody public ResultDTO listFiles(@RequestParam(defaultValue = "1") Integer pageNum) { try { PageHelper.startPage(pageNum, 10); List<FileStatus> fileStatuses = hdfsService.listFiles("/"); PageInfo<FileStatus> pageInfo = new PageInfo<>(fileStatuses); Map<String, Object> data = new HashMap<>(); data.put("list", fileStatuses); data.put("pageNum", pageInfo.getPageNum()); data.put("pages", pageInfo.getPages()); data.put("total", pageInfo.getTotal()); data.put("prePage", pageInfo.getPrePage()); data.put("nextPage", pageInfo.getNextPage()); return ResultDTO.success(data); } catch (IOException e) { return ResultDTO.fail("获取文件列表失败:" + e.getMessage()); } } // 上传文件 @PostMapping("/upload") @ResponseBody public ResultDTO uploadFile(@RequestParam("file") MultipartFile file) { try { if (file.isEmpty()) { return ResultDTO.fail("上传文件不能为空"); } String fileName = file.getOriginalFilename(); String filePath = "/uploads/" + fileName; boolean result = hdfsService.uploadFile(file.getInputStream(), filePath); if (result) { return ResultDTO.success("上传成功"); } else { return ResultDTO.fail("上传失败"); } } catch (IOException e) { return ResultDTO.fail("上传失败:" + e.getMessage()); } } // 删除文件 @PostMapping("/delete") @ResponseBody public ResultDTO deleteFile(@RequestParam String path) { try { boolean result = hdfsService.deleteFile(path); if (result) { return ResultDTO.success("删除成功"); } else { return ResultDTO.fail("删除失败"); } } catch (IOException e) { return ResultDTO.fail("删除失败:" + e.getMessage()); } } // 下载文件 @GetMapping("/download") @ResponseBody public void downloadFile(@RequestParam String path, HttpServletResponse response) { try { InputStream inputStream = hdfsService.readFile(path); response.setContentType("application/octet-stream"); response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(path.substring(path.lastIndexOf("/") + 1), "UTF-8")); IOUtils.copy(inputStream, response.getOutputStream()); response.flushBuffer(); } catch (IOException e) { e.printStackTrace(); } } ```

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值