Spring Boot Failed to load resource: the server responded with a status of 404How to respond with HTTP 400 error in a Spring MVC @ResponseBody method returning String?Add context path to Spring Boot applicationHow to configure port for a Spring Boot applicationSpring Boot not serving static contentspring boot do not publish correctly font files from static dir (font-awesome)How to log SQL statements in Spring Boot?Failed to load resource: the server responded with a status of 404 (Not Found) in spring mvcDifference between Spring MVC and Spring BootFailed to load resource: the server responded with a status of 404Failed to load resource: the server responded with a status of 404?
Signing using digital signatures?
What happens when your group is victim of a surprise attack but you can't be surprised?
Word Wall of Whimsical Wordy Whatchamacallits
What does 2>&1 | tee mean?
Can gpxpy write .gpx file?
Should I include salary information on my CV?
The use of "I" and "we" used in the same sentence and other questions
Generate and Graph the Recamán Sequence
How can I check type T is among parameter pack Ts... in C++?
How often can a PC check with passive perception during a combat turn?
What do you call the action of someone tackling a stronger person?
Stepcounter after paragraph
Alphabet completion rate
Does anycast addressing add additional latency in any way?
“Faire” being used to mean “avoir l’air”?
Confusion about multiple information Sets
How fast can a ship with rotating habitats be accelerated?
How do I find and plot the intersection of these three surfaces?
Wilcoxon signed rank test – critical value for n>50
How well known and how commonly used was Huffman coding in 1979?
Children's short story about material that accelerates away from gravity
Are Finite Automata Turing Complete?
Should I tell my insurance company I have an unsecured loan for my new car?
Anagram Within an Anagram!
Spring Boot Failed to load resource: the server responded with a status of 404
How to respond with HTTP 400 error in a Spring MVC @ResponseBody method returning String?Add context path to Spring Boot applicationHow to configure port for a Spring Boot applicationSpring Boot not serving static contentspring boot do not publish correctly font files from static dir (font-awesome)How to log SQL statements in Spring Boot?Failed to load resource: the server responded with a status of 404 (Not Found) in spring mvcDifference between Spring MVC and Spring BootFailed to load resource: the server responded with a status of 404Failed to load resource: the server responded with a status of 404?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I am facing this error:

Failed to load resource: the server responded with a status of 404
Here is how I am loading css. Note that I am not using WebMvcConfigurer.
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<title>Material Design Bootstrap</title>
<!-- Font Awesome -->
<link rel="stylesheet" th:href="@https://maxcdn.bootstrapcdn.com/font-awesome/4.6.0/css/font-awesome.min.css">
<!-- Bootstrap core CSS -->
<link rel="stylesheet" th:href="@/css/bootstrap.min.css">
<!-- Material Design Bootstrap -->
<link rel="stylesheet" th:href="@/css/mdb.min.css">
<!-- Your custom styles (optional) -->
<link rel="stylesheet" th:href="@/css/style.css">
</head>
And I am loading js files at the end of the page (body).
<body>
......
<!-- SCRIPTS -->
<!-- JQuery -->
<script type="text/javascript" src="/static/js/jquery-3.1.1.min.js" th:src="@/js/jquery-3.1.1.min.js"></script>
<!-- Bootstrap tooltips -->
<script type="text/javascript" src="/static/js/popper.min.js" th:src="@/js/popper.min.js"></script>
<!-- Bootstrap core JavaScript -->
<script type="text/javascript" src="/static/js/bootstrap.min.js" th:src="@/js/bootstrap.min.js"></script>
<!-- MDB core JavaScript -->
<script type="text/javascript" src="/static/js/mdb.min.js" th:src="@/js/mdb.min.js"></script>
</body>
What could be the reason?
EDIT:
Here is my directory structure

spring spring-mvc spring-boot
add a comment |
I am facing this error:

Failed to load resource: the server responded with a status of 404
Here is how I am loading css. Note that I am not using WebMvcConfigurer.
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<title>Material Design Bootstrap</title>
<!-- Font Awesome -->
<link rel="stylesheet" th:href="@https://maxcdn.bootstrapcdn.com/font-awesome/4.6.0/css/font-awesome.min.css">
<!-- Bootstrap core CSS -->
<link rel="stylesheet" th:href="@/css/bootstrap.min.css">
<!-- Material Design Bootstrap -->
<link rel="stylesheet" th:href="@/css/mdb.min.css">
<!-- Your custom styles (optional) -->
<link rel="stylesheet" th:href="@/css/style.css">
</head>
And I am loading js files at the end of the page (body).
<body>
......
<!-- SCRIPTS -->
<!-- JQuery -->
<script type="text/javascript" src="/static/js/jquery-3.1.1.min.js" th:src="@/js/jquery-3.1.1.min.js"></script>
<!-- Bootstrap tooltips -->
<script type="text/javascript" src="/static/js/popper.min.js" th:src="@/js/popper.min.js"></script>
<!-- Bootstrap core JavaScript -->
<script type="text/javascript" src="/static/js/bootstrap.min.js" th:src="@/js/bootstrap.min.js"></script>
<!-- MDB core JavaScript -->
<script type="text/javascript" src="/static/js/mdb.min.js" th:src="@/js/mdb.min.js"></script>
</body>
What could be the reason?
EDIT:
Here is my directory structure

spring spring-mvc spring-boot
What's your directory structure?
– ISlimani
Jun 27 '18 at 0:30
@DforTye I have added directory structure. Please have a look.
– Faizan Mubasher
Jun 27 '18 at 5:03
add a comment |
I am facing this error:

Failed to load resource: the server responded with a status of 404
Here is how I am loading css. Note that I am not using WebMvcConfigurer.
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<title>Material Design Bootstrap</title>
<!-- Font Awesome -->
<link rel="stylesheet" th:href="@https://maxcdn.bootstrapcdn.com/font-awesome/4.6.0/css/font-awesome.min.css">
<!-- Bootstrap core CSS -->
<link rel="stylesheet" th:href="@/css/bootstrap.min.css">
<!-- Material Design Bootstrap -->
<link rel="stylesheet" th:href="@/css/mdb.min.css">
<!-- Your custom styles (optional) -->
<link rel="stylesheet" th:href="@/css/style.css">
</head>
And I am loading js files at the end of the page (body).
<body>
......
<!-- SCRIPTS -->
<!-- JQuery -->
<script type="text/javascript" src="/static/js/jquery-3.1.1.min.js" th:src="@/js/jquery-3.1.1.min.js"></script>
<!-- Bootstrap tooltips -->
<script type="text/javascript" src="/static/js/popper.min.js" th:src="@/js/popper.min.js"></script>
<!-- Bootstrap core JavaScript -->
<script type="text/javascript" src="/static/js/bootstrap.min.js" th:src="@/js/bootstrap.min.js"></script>
<!-- MDB core JavaScript -->
<script type="text/javascript" src="/static/js/mdb.min.js" th:src="@/js/mdb.min.js"></script>
</body>
What could be the reason?
EDIT:
Here is my directory structure

spring spring-mvc spring-boot
I am facing this error:

Failed to load resource: the server responded with a status of 404
Here is how I am loading css. Note that I am not using WebMvcConfigurer.
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<title>Material Design Bootstrap</title>
<!-- Font Awesome -->
<link rel="stylesheet" th:href="@https://maxcdn.bootstrapcdn.com/font-awesome/4.6.0/css/font-awesome.min.css">
<!-- Bootstrap core CSS -->
<link rel="stylesheet" th:href="@/css/bootstrap.min.css">
<!-- Material Design Bootstrap -->
<link rel="stylesheet" th:href="@/css/mdb.min.css">
<!-- Your custom styles (optional) -->
<link rel="stylesheet" th:href="@/css/style.css">
</head>
And I am loading js files at the end of the page (body).
<body>
......
<!-- SCRIPTS -->
<!-- JQuery -->
<script type="text/javascript" src="/static/js/jquery-3.1.1.min.js" th:src="@/js/jquery-3.1.1.min.js"></script>
<!-- Bootstrap tooltips -->
<script type="text/javascript" src="/static/js/popper.min.js" th:src="@/js/popper.min.js"></script>
<!-- Bootstrap core JavaScript -->
<script type="text/javascript" src="/static/js/bootstrap.min.js" th:src="@/js/bootstrap.min.js"></script>
<!-- MDB core JavaScript -->
<script type="text/javascript" src="/static/js/mdb.min.js" th:src="@/js/mdb.min.js"></script>
</body>
What could be the reason?
EDIT:
Here is my directory structure

spring spring-mvc spring-boot
spring spring-mvc spring-boot
edited Jun 27 '18 at 5:02
Faizan Mubasher
asked Jun 26 '18 at 13:29
Faizan MubasherFaizan Mubasher
2,3043 gold badges23 silver badges49 bronze badges
2,3043 gold badges23 silver badges49 bronze badges
What's your directory structure?
– ISlimani
Jun 27 '18 at 0:30
@DforTye I have added directory structure. Please have a look.
– Faizan Mubasher
Jun 27 '18 at 5:03
add a comment |
What's your directory structure?
– ISlimani
Jun 27 '18 at 0:30
@DforTye I have added directory structure. Please have a look.
– Faizan Mubasher
Jun 27 '18 at 5:03
What's your directory structure?
– ISlimani
Jun 27 '18 at 0:30
What's your directory structure?
– ISlimani
Jun 27 '18 at 0:30
@DforTye I have added directory structure. Please have a look.
– Faizan Mubasher
Jun 27 '18 at 5:03
@DforTye I have added directory structure. Please have a look.
– Faizan Mubasher
Jun 27 '18 at 5:03
add a comment |
3 Answers
3
active
oldest
votes
Seems you are doing mistake while you are loading jquery. Your jquery is jquery-3.3.1.min.js but you are loading jquery-3.1.1.min.js
<script type="text/javascript" src="/static/js/jquery-3.1.1.min.js" th:src="@/js/jquery-3.1.1.min.js"></script>
So check jquery version.
Oh man you got it right. Such a silly mistake. Thanks anyway.
– Faizan Mubasher
Jun 27 '18 at 5:55
My pleasure man.
– Avijit Barua
Jun 27 '18 at 5:57
add a comment |

Load css
<link href="../static/assets/css/materialize.min.css" type="text/css"
rel="stylesheet" th:href="@/assets/css/materialize.min.css"
media="screen,projection">
Load js
<script type="text/javascript" src="../static/assets/js/materialize.min.js"
th:src="@/assets/js/materialize.min.js"></script>
I have added my directory structure. Please have a look.
– Faizan Mubasher
Jun 27 '18 at 5:11
add a comment |
this worked for me.
this is how my files are like in the static folder: 
this is how i include the files from the static folder into my html pages:
i get rid of the static folder in the path since the server i guess knows to look for static content in the static folder. so the path for my all.min.css will be.
http://127.0.0.1:8080/js/demo/all.min.css
it will search for in the static folder.
if you add static i.e
link href="/static/vendor/fontawesome-free/css/all.min.css" rel="stylesheet" type="text/css"
the server will look for
http://127.0.0.1:8080/static/static/js/demo/all.min.css
and it won't get that path
remember to allow the routes in antmatchers if you're using spring security. see attached image
allow the routes to the folders in static folder if using spring security:
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f51044143%2fspring-boot-failed-to-load-resource-the-server-responded-with-a-status-of-404%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
Seems you are doing mistake while you are loading jquery. Your jquery is jquery-3.3.1.min.js but you are loading jquery-3.1.1.min.js
<script type="text/javascript" src="/static/js/jquery-3.1.1.min.js" th:src="@/js/jquery-3.1.1.min.js"></script>
So check jquery version.
Oh man you got it right. Such a silly mistake. Thanks anyway.
– Faizan Mubasher
Jun 27 '18 at 5:55
My pleasure man.
– Avijit Barua
Jun 27 '18 at 5:57
add a comment |
Seems you are doing mistake while you are loading jquery. Your jquery is jquery-3.3.1.min.js but you are loading jquery-3.1.1.min.js
<script type="text/javascript" src="/static/js/jquery-3.1.1.min.js" th:src="@/js/jquery-3.1.1.min.js"></script>
So check jquery version.
Oh man you got it right. Such a silly mistake. Thanks anyway.
– Faizan Mubasher
Jun 27 '18 at 5:55
My pleasure man.
– Avijit Barua
Jun 27 '18 at 5:57
add a comment |
Seems you are doing mistake while you are loading jquery. Your jquery is jquery-3.3.1.min.js but you are loading jquery-3.1.1.min.js
<script type="text/javascript" src="/static/js/jquery-3.1.1.min.js" th:src="@/js/jquery-3.1.1.min.js"></script>
So check jquery version.
Seems you are doing mistake while you are loading jquery. Your jquery is jquery-3.3.1.min.js but you are loading jquery-3.1.1.min.js
<script type="text/javascript" src="/static/js/jquery-3.1.1.min.js" th:src="@/js/jquery-3.1.1.min.js"></script>
So check jquery version.
answered Jun 27 '18 at 5:39
Avijit BaruaAvijit Barua
1,7171 gold badge3 silver badges22 bronze badges
1,7171 gold badge3 silver badges22 bronze badges
Oh man you got it right. Such a silly mistake. Thanks anyway.
– Faizan Mubasher
Jun 27 '18 at 5:55
My pleasure man.
– Avijit Barua
Jun 27 '18 at 5:57
add a comment |
Oh man you got it right. Such a silly mistake. Thanks anyway.
– Faizan Mubasher
Jun 27 '18 at 5:55
My pleasure man.
– Avijit Barua
Jun 27 '18 at 5:57
Oh man you got it right. Such a silly mistake. Thanks anyway.
– Faizan Mubasher
Jun 27 '18 at 5:55
Oh man you got it right. Such a silly mistake. Thanks anyway.
– Faizan Mubasher
Jun 27 '18 at 5:55
My pleasure man.
– Avijit Barua
Jun 27 '18 at 5:57
My pleasure man.
– Avijit Barua
Jun 27 '18 at 5:57
add a comment |

Load css
<link href="../static/assets/css/materialize.min.css" type="text/css"
rel="stylesheet" th:href="@/assets/css/materialize.min.css"
media="screen,projection">
Load js
<script type="text/javascript" src="../static/assets/js/materialize.min.js"
th:src="@/assets/js/materialize.min.js"></script>
I have added my directory structure. Please have a look.
– Faizan Mubasher
Jun 27 '18 at 5:11
add a comment |

Load css
<link href="../static/assets/css/materialize.min.css" type="text/css"
rel="stylesheet" th:href="@/assets/css/materialize.min.css"
media="screen,projection">
Load js
<script type="text/javascript" src="../static/assets/js/materialize.min.js"
th:src="@/assets/js/materialize.min.js"></script>
I have added my directory structure. Please have a look.
– Faizan Mubasher
Jun 27 '18 at 5:11
add a comment |

Load css
<link href="../static/assets/css/materialize.min.css" type="text/css"
rel="stylesheet" th:href="@/assets/css/materialize.min.css"
media="screen,projection">
Load js
<script type="text/javascript" src="../static/assets/js/materialize.min.js"
th:src="@/assets/js/materialize.min.js"></script>

Load css
<link href="../static/assets/css/materialize.min.css" type="text/css"
rel="stylesheet" th:href="@/assets/css/materialize.min.css"
media="screen,projection">
Load js
<script type="text/javascript" src="../static/assets/js/materialize.min.js"
th:src="@/assets/js/materialize.min.js"></script>
answered Jun 27 '18 at 0:36
ISlimaniISlimani
8626 silver badges12 bronze badges
8626 silver badges12 bronze badges
I have added my directory structure. Please have a look.
– Faizan Mubasher
Jun 27 '18 at 5:11
add a comment |
I have added my directory structure. Please have a look.
– Faizan Mubasher
Jun 27 '18 at 5:11
I have added my directory structure. Please have a look.
– Faizan Mubasher
Jun 27 '18 at 5:11
I have added my directory structure. Please have a look.
– Faizan Mubasher
Jun 27 '18 at 5:11
add a comment |
this worked for me.
this is how my files are like in the static folder: 
this is how i include the files from the static folder into my html pages:
i get rid of the static folder in the path since the server i guess knows to look for static content in the static folder. so the path for my all.min.css will be.
http://127.0.0.1:8080/js/demo/all.min.css
it will search for in the static folder.
if you add static i.e
link href="/static/vendor/fontawesome-free/css/all.min.css" rel="stylesheet" type="text/css"
the server will look for
http://127.0.0.1:8080/static/static/js/demo/all.min.css
and it won't get that path
remember to allow the routes in antmatchers if you're using spring security. see attached image
allow the routes to the folders in static folder if using spring security:
add a comment |
this worked for me.
this is how my files are like in the static folder: 
this is how i include the files from the static folder into my html pages:
i get rid of the static folder in the path since the server i guess knows to look for static content in the static folder. so the path for my all.min.css will be.
http://127.0.0.1:8080/js/demo/all.min.css
it will search for in the static folder.
if you add static i.e
link href="/static/vendor/fontawesome-free/css/all.min.css" rel="stylesheet" type="text/css"
the server will look for
http://127.0.0.1:8080/static/static/js/demo/all.min.css
and it won't get that path
remember to allow the routes in antmatchers if you're using spring security. see attached image
allow the routes to the folders in static folder if using spring security:
add a comment |
this worked for me.
this is how my files are like in the static folder: 
this is how i include the files from the static folder into my html pages:
i get rid of the static folder in the path since the server i guess knows to look for static content in the static folder. so the path for my all.min.css will be.
http://127.0.0.1:8080/js/demo/all.min.css
it will search for in the static folder.
if you add static i.e
link href="/static/vendor/fontawesome-free/css/all.min.css" rel="stylesheet" type="text/css"
the server will look for
http://127.0.0.1:8080/static/static/js/demo/all.min.css
and it won't get that path
remember to allow the routes in antmatchers if you're using spring security. see attached image
allow the routes to the folders in static folder if using spring security:
this worked for me.
this is how my files are like in the static folder: 
this is how i include the files from the static folder into my html pages:
i get rid of the static folder in the path since the server i guess knows to look for static content in the static folder. so the path for my all.min.css will be.
http://127.0.0.1:8080/js/demo/all.min.css
it will search for in the static folder.
if you add static i.e
link href="/static/vendor/fontawesome-free/css/all.min.css" rel="stylesheet" type="text/css"
the server will look for
http://127.0.0.1:8080/static/static/js/demo/all.min.css
and it won't get that path
remember to allow the routes in antmatchers if you're using spring security. see attached image
allow the routes to the folders in static folder if using spring security:
edited Mar 25 at 11:40
Armali
8,23012 gold badges39 silver badges108 bronze badges
8,23012 gold badges39 silver badges108 bronze badges
answered Mar 25 at 11:17
bugzbugz
113 bronze badges
113 bronze badges
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f51044143%2fspring-boot-failed-to-load-resource-the-server-responded-with-a-status-of-404%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
What's your directory structure?
– ISlimani
Jun 27 '18 at 0:30
@DforTye I have added directory structure. Please have a look.
– Faizan Mubasher
Jun 27 '18 at 5:03