user3331535
user3331535

Reputation: 1257

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

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

Upvotes: 118

Views: 1935280

Answers (14)

philipp-robin
philipp-robin

Reputation: 71

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

Upvotes: 0

Sonu Chohan
Sonu Chohan

Reputation: 273

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

Upvotes: 0

Md Khairul Islam
Md Khairul Islam

Reputation: 461

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

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

replace by

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

Upvotes: 4

Keensleeeeeeee
Keensleeeeeeee

Reputation: 1246

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>

Upvotes: 98

Deep Adhia
Deep Adhia

Reputation: 393

Please install App Script for Ionic 3 Solution

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

Upvotes: 0

Kipruto
Kipruto

Reputation: 857

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

Upvotes: 1

Abdullah
Abdullah

Reputation: 1021

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

Upvotes: 0

Swapnil G Thaware
Swapnil G Thaware

Reputation: 877

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.

Upvotes: 4

Metin Atalay
Metin Atalay

Reputation: 1517

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

Upvotes: 1

Indranil
Indranil

Reputation: 2703

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>

Upvotes: 3

Ifesinachi Bryan
Ifesinachi Bryan

Reputation: 2358

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

Upvotes: 5

Hameed Syed
Hameed Syed

Reputation: 4215

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

Upvotes: 0

Prasad Joshi
Prasad Joshi

Reputation: 471

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>

Upvotes: 7

Paul
Paul

Reputation: 1502

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.

Upvotes: 19

Related Questions