117

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

3
  • its working now according to his answer @Geddemet Commented Mar 11, 2014 at 5:47
  • Then please accept his answer with the green checkbox by the voting arrows. Commented Mar 11, 2014 at 5:48
  • magento.stackexchange.com/questions/96032/… i refer you to check this issue here Commented Apr 5, 2016 at 21:24

14 Answers 14

99

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> 
Sign up to request clarification or add additional context in comments.

4 Comments

I was facing the same issue with a font. It works fine now . :)
I was getting an error - "Failed to load resource: the server responded with a status of 404 (NOT FOUND)". This solution worked for me.
My path is correct but it still gives me this error: undefined:1 GET localhost/e-commerce/undefined 404 (Not Found)
my files were in a completely other folder lol, and this answer helped me realize that
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.

Comments

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> 

4 Comments

I'm using Asp.net I'v edited my web.config as mentioned, then I started getting error 500
Error status 500 is related to resource not found... please check which resources are you mission....
I get the error for the font file. not for the whole page
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" /> 

Comments

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.

Comments

4

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

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

replace by

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

Comments

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> 

Comments

1

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

Comments

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

Comments

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

Comments

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

Comments

0

Please install App Script for Ionic 3 Solution

npm i -D -E @ionic/app-scripts 

Comments

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

1 Comment

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.