Failed to load resource: the server responded with a status of 404 (Not Found)
Asked Answered
I

14

111

I can't solve my link problem. Could you help on to this to link CSS and JS File?

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>

Error:

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

Refer this link Directory structure.

enter image description here

Implead answered 11/3, 2014 at 5:32 Comment(3)
its working now according to his answer @GeddemetImplead
Then please accept his answer with the green checkbox by the voting arrows.Maracaibo
magento.stackexchange.com/questions/96032/… i refer you to check this issue hereCalvary
H
96

Your files are not under the jsp folder that's why it is not found. You have to go back again 1 folder Try this:

<script src="../../Jquery/prettify.js"></script>
Helpless answered 11/3, 2014 at 5:43 Comment(4)
I was facing the same issue with a font. It works fine now . :)Idola
I was getting an error - "Failed to load resource: the server responded with a status of 404 (NOT FOUND)". This solution worked for me.Skiplane
My path is correct but it still gives me this error: undefined:1 GET localhost/e-commerce/undefined 404 (Not Found)Enduring
my files were in a completely other folder lol, and this answer helped me realize thatOenone
A
19

Note the failing URL:

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

Now examine one of your links:

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

The "../" is shorthand for "The containing directory", or "Up one directory". This is a relative URL. At a guess, you have a file in /jsp/<somefolder>/ which contains the <link /> and <style /> elements.

I recommend using an absolute URL:

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

The reason for using an absolute url is that I'm guessing the links are contained in some common file. If you attempt to correct your relative pathing by adding a second "../", you may break any files contained in /jsp.

Austenite answered 11/3, 2014 at 5:43 Comment(0)
C
7

If you have resource with woff extension and getting error then add following code in your web.config application will help to fix.

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

For Resources like JavaScript or CSS not found then provide the path of adding link or script in following way

<link ref="@(Url.Content("path of css"))" rel="stylesheet">

<script src="@(Url.Content("path of js"))" type="text/javascript"></script>
Cockrell answered 29/7, 2016 at 7:9 Comment(4)
I'm using Asp.net I'v edited my web.config as mentioned, then I started getting error 500Athodyd
Error status 500 is related to resource not found... please check which resources are you mission....Cockrell
You can also check #5386214Cockrell
I get the error for the font file. not for the whole pageAthodyd
P
5

Add this to your Configuration file. Then put all your resources(eg. img,css,js etc) into the src > main > webapp > resources directory.

public class Config extends WebMvcConfigurerAdapter{
   @Override
   public void addResourceHandlers(ResourceHandlerRegistry registry) {  
    registry.addResourceHandler("/resources/**").addResourceLocations("/resources/");
   }
}

After this, you can access your resources like this.

<link href="${pageContext.request.contextPath}/resources/assets/css/demo.css" rel="stylesheet" />
Patrizia answered 24/11, 2017 at 20:7 Comment(0)
F
4

If your URL is:

http://127.0.0.1:8080/binding/

Update the below property in the index.html

<base href="/binding/">

In short, you need to check the locations of the files.

Franci answered 11/2, 2019 at 10:46 Comment(0)
C
3

Add this below code(<handler>) on your web.config within <system.webServer>:

<system.webServer>
<handlers>
  <remove name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" />
  <remove name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" />
  <remove name="ExtensionlessUrlHandler-Integrated-4.0" />
  <add name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness32" responseBufferLimit="0" />
  <add name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness64" responseBufferLimit="0" />
  <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
</handlers>
</system.webServer>
Cardinal answered 21/9, 2018 at 9:54 Comment(0)
S
3

If you are loading js from same folder just use forward slash

<script src="bundle.js"></script> 

replace by

<script src="/bundle.js"></script>
Systaltic answered 23/7, 2022 at 1:2 Comment(0)
S
1

I have added app.UseStaticFiles(); this code in my startup.cs than it is fixed

Seften answered 31/10, 2018 at 6:18 Comment(0)
C
1

I was having this exact issue and this was because I was returning images from a server into component that is 1 step down the path. This what I mean. See file arrangement

*projectfolder/phpfiles/component.php*

Now my images folder was located here projectfolder/images/

Now I fixed it by adding ../ so that it could skip 1 step backwards

Goodluck

Cling answered 20/6, 2020 at 12:57 Comment(0)
D
0

Please note , you might need to disable adblocks if necessary. Drag and drop off script path in visual studio doesn't work if you are using HTML pages but it does work for mvc ,asp.netwebforms. I figured this after one hour

Dysgenics answered 29/8, 2016 at 6:55 Comment(0)
M
0

Please install App Script for Ionic 3 Solution

npm i -D -E @ionic/app-scripts
Mose answered 27/8, 2018 at 5:28 Comment(0)
G
0

For me the error was the files under js folder not included in the project this solve my issue :

1- In the solution explorer toolbar click Show All Files.

2- open js folder and select all files under the folder

3- right click then select include In Project

4- Save and build your application then its working correct and load .css and .js files

Gaige answered 13/6, 2020 at 6:51 Comment(0)
P
0
// To fix this issue, please add the below changes to src/index.html
For example : ( add project name or project root path ) 
<base href="/enter_project_folder_name/">
Prehension answered 13/7, 2023 at 13:9 Comment(1)
Answer needs supporting information Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.Shopwindow
F
0

For me the Error was simply, that the font file name had whitespaces:
TT Interphases Pro Mono Trial Italic.tt
Change it to
TT_Interphases_Pro_Mono_Trial_Italic.ttf

Ferrick answered 22/12, 2023 at 19:45 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.