无法加载资源:服务器响应状态为404(未找到)

 乾岳_349 发布于 2023-01-18 19:00

我无法解决我的链接问题.你能帮忙解决这个问题,将CSS和JS文件联系起来吗?

CSS:




JS:



错误:

Failed to load resource: the server responded with a status of 404 (Not Found) http://localhost:8080/RetailSmart/jsp/Jquery/jquery.multiselect.css
Failed to load resource: the server responded with a status of 404 (Not Found) http://localhost:8080/RetailSmart/jsp/Jquery/style.css
Failed to load resource: the server responded with a status of 404 (Not Found) http://localhost:8080/RetailSmart/jsp/Jquery/prettify.css
Failed to load resource: the server responded with a status of 404 (Not Found) http://localhost:8080/RetailSmart/jsp/Jquery/jquery.multiselect.js
Failed to load resource: the server responded with a status of 404 (Not Found) http://localhost:8080/RetailSmart/jsp/Jquery/prettify.js

请参阅此链接目录结构.

在此输入图像描述

3 个回答
  • 请注意失败的网址:

    Failed ... http://localhost:8080/RetailSmart/jsp/Jquery/jquery.multiselect.css
    

    现在检查一下你的链接:

    <link href="../Jquery/jquery.multiselect.css" rel="stylesheet"/>
    

    "../"是"包含目录"或"向上一个目录"的简写.这是一个相对 URL.猜测,/ jsp/<somefolder> /中有一个文件,其中包含<link />和<style />元素.

    我建议使用绝对 URL:

    <link href="/RetailSmart/Jquery/jquery.multiselect.css" rel="stylesheet"/>
    

    使用绝对URL的原因是我猜测链接包含在一些常见文件中.如果您尝试通过添加第二个"../"来更正相对路径,则可能会破坏/ jsp中包含的任何文件.

    2023-01-18 19:03 回答
  • 您的文件不在jsp文件夹下,这就是找不到它的原因.你必须再回去1个文件夹试试这个:

         <script  src="../../Jquery/prettify.js"></script>
    

    2023-01-18 19:03 回答
  • 如果您的资源具有woff扩展并且收到错误,那么在web.config应用程序中添加以下代码将有助于修复.

    <system.webServer>
    <staticContent>
       <mimeMap fileExtension=".woff" mimeType="application/x-font-woff" />
    </staticContent>
    </system.webServer>
    

    对于未找到的JavaScript或CSS等资源,请按以下方式提供添加链接或脚本的路径

    <link ref="@(Url.Content("path of css"))" rel="stylesheet">
    
    <script src="@(Url.Content("path of js"))" type="text/javascript"></script>
    

    2023-01-18 19:03 回答
撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有