others - javascript加载资源失败: 服务器响应的状态为 404 (Not Found)

css :


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


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


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



JS :


<script src="../Jquery/jquery.multiselect.js"></script>


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



错误:


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



https://www.dropbox.com/s/31pwda3u4is4qz0/link.png引用此链接目录结构。

时间:

你的文件不在jsp文件夹下,这就是找不到它的原因,你必须再次返回文件夹,请尝试以下操作:


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



请注意失败的URL:


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



现在检查你的一个链接:


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



我建议使用绝对URL:


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




<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>



将它添加到配置文件中,然后把所有的资源(例如,img,css,js等)进入src > main > web app > resources目录。


public class Config extends WebMvcConfigurerAdapter{


 @Override


 public void addResourceHandlers(ResourceHandlerRegistry registry) { 


 registry.addResourceHandler("/resources/**").addResourceLocations("/resources/");


 }


}



在此之后,你可以像这样访问资源。


<link href="${pageContext.request.contextPath}/resources/assets/css/demo.css" rel="stylesheet" />



...