Eclipse vs. Spring Boot gives JSP error: Fragment “/js/home.js” was not found at expected path /src/main/webapp/js/home.js
I have the line
<script type="text/javascript">
<%@include file="/js/home.js" %>
Which gives the error in title. The JS files are in /src/main/resources/static/js
. The error goes away if I create /src/main/webapp/js/home.js
. This answer says webapp/
is not recommended. https://stackoverflow.com/a/28727189/148844. We are using JARs and we are uploading a WAR to AWS via the web console. Eclipse expects webapp/js/
and Spring Boot expects resources/static/js
, so which should I use? How do I tell Eclipse how to find the JS file?
$ tree
├───src
│ ├───main
│ │ ├───java
│ │ ├───resources
│ │ │ └───static
│ │ │ ├───css
│ │ │ ├───fonts
│ │ │ ├───img
│ │ │ └───js
│ │ └───webapp
│ │ └───WEB-INF
│ │ └───jsp
We also have
spring.mvc.view.prefix: /WEB-INF/jsp/
spring.mvc.view.suffix: .jsp
Eclipse Version: Photon Release (4.8.0)
spring eclipse jsp spring-boot jar
add a comment |
I have the line
<script type="text/javascript">
<%@include file="/js/home.js" %>
Which gives the error in title. The JS files are in /src/main/resources/static/js
. The error goes away if I create /src/main/webapp/js/home.js
. This answer says webapp/
is not recommended. https://stackoverflow.com/a/28727189/148844. We are using JARs and we are uploading a WAR to AWS via the web console. Eclipse expects webapp/js/
and Spring Boot expects resources/static/js
, so which should I use? How do I tell Eclipse how to find the JS file?
$ tree
├───src
│ ├───main
│ │ ├───java
│ │ ├───resources
│ │ │ └───static
│ │ │ ├───css
│ │ │ ├───fonts
│ │ │ ├───img
│ │ │ └───js
│ │ └───webapp
│ │ └───WEB-INF
│ │ └───jsp
We also have
spring.mvc.view.prefix: /WEB-INF/jsp/
spring.mvc.view.suffix: .jsp
Eclipse Version: Photon Release (4.8.0)
spring eclipse jsp spring-boot jar
I changed it to<script src="/js/home.js" type="text/javascript"></script>
for the time being.
– Chloe
Nov 12 '18 at 21:39
A comment in the answer you linked clarifies, do not use/src/main/webapp
if you are packaging as as JAR, not strictly using JARs. You are packaging as WAR.
– Edwin Diaz-Mendez
Nov 12 '18 at 22:17
@EdwinDiaz-Mendez OK but it says it will silently fail for other tools. If we wish to switch to maybe WebLogic or another servlet container, I would like to make the app as portable as possible without having it silently fail or require lots of code-rework. We are also working on automated deployments from Git so it would no longer be in a WAR/JAR format then (maybe). Basically I want to stick with best, most accepted practices, even if we can get away with it in our special niche circumstance.
– Chloe
Nov 13 '18 at 21:03
add a comment |
I have the line
<script type="text/javascript">
<%@include file="/js/home.js" %>
Which gives the error in title. The JS files are in /src/main/resources/static/js
. The error goes away if I create /src/main/webapp/js/home.js
. This answer says webapp/
is not recommended. https://stackoverflow.com/a/28727189/148844. We are using JARs and we are uploading a WAR to AWS via the web console. Eclipse expects webapp/js/
and Spring Boot expects resources/static/js
, so which should I use? How do I tell Eclipse how to find the JS file?
$ tree
├───src
│ ├───main
│ │ ├───java
│ │ ├───resources
│ │ │ └───static
│ │ │ ├───css
│ │ │ ├───fonts
│ │ │ ├───img
│ │ │ └───js
│ │ └───webapp
│ │ └───WEB-INF
│ │ └───jsp
We also have
spring.mvc.view.prefix: /WEB-INF/jsp/
spring.mvc.view.suffix: .jsp
Eclipse Version: Photon Release (4.8.0)
spring eclipse jsp spring-boot jar
I have the line
<script type="text/javascript">
<%@include file="/js/home.js" %>
Which gives the error in title. The JS files are in /src/main/resources/static/js
. The error goes away if I create /src/main/webapp/js/home.js
. This answer says webapp/
is not recommended. https://stackoverflow.com/a/28727189/148844. We are using JARs and we are uploading a WAR to AWS via the web console. Eclipse expects webapp/js/
and Spring Boot expects resources/static/js
, so which should I use? How do I tell Eclipse how to find the JS file?
$ tree
├───src
│ ├───main
│ │ ├───java
│ │ ├───resources
│ │ │ └───static
│ │ │ ├───css
│ │ │ ├───fonts
│ │ │ ├───img
│ │ │ └───js
│ │ └───webapp
│ │ └───WEB-INF
│ │ └───jsp
We also have
spring.mvc.view.prefix: /WEB-INF/jsp/
spring.mvc.view.suffix: .jsp
Eclipse Version: Photon Release (4.8.0)
spring eclipse jsp spring-boot jar
spring eclipse jsp spring-boot jar
edited Nov 12 '18 at 21:39
Chloe
asked Nov 12 '18 at 21:14
ChloeChloe
10.7k1876192
10.7k1876192
I changed it to<script src="/js/home.js" type="text/javascript"></script>
for the time being.
– Chloe
Nov 12 '18 at 21:39
A comment in the answer you linked clarifies, do not use/src/main/webapp
if you are packaging as as JAR, not strictly using JARs. You are packaging as WAR.
– Edwin Diaz-Mendez
Nov 12 '18 at 22:17
@EdwinDiaz-Mendez OK but it says it will silently fail for other tools. If we wish to switch to maybe WebLogic or another servlet container, I would like to make the app as portable as possible without having it silently fail or require lots of code-rework. We are also working on automated deployments from Git so it would no longer be in a WAR/JAR format then (maybe). Basically I want to stick with best, most accepted practices, even if we can get away with it in our special niche circumstance.
– Chloe
Nov 13 '18 at 21:03
add a comment |
I changed it to<script src="/js/home.js" type="text/javascript"></script>
for the time being.
– Chloe
Nov 12 '18 at 21:39
A comment in the answer you linked clarifies, do not use/src/main/webapp
if you are packaging as as JAR, not strictly using JARs. You are packaging as WAR.
– Edwin Diaz-Mendez
Nov 12 '18 at 22:17
@EdwinDiaz-Mendez OK but it says it will silently fail for other tools. If we wish to switch to maybe WebLogic or another servlet container, I would like to make the app as portable as possible without having it silently fail or require lots of code-rework. We are also working on automated deployments from Git so it would no longer be in a WAR/JAR format then (maybe). Basically I want to stick with best, most accepted practices, even if we can get away with it in our special niche circumstance.
– Chloe
Nov 13 '18 at 21:03
I changed it to
<script src="/js/home.js" type="text/javascript"></script>
for the time being.– Chloe
Nov 12 '18 at 21:39
I changed it to
<script src="/js/home.js" type="text/javascript"></script>
for the time being.– Chloe
Nov 12 '18 at 21:39
A comment in the answer you linked clarifies, do not use
/src/main/webapp
if you are packaging as as JAR, not strictly using JARs. You are packaging as WAR.– Edwin Diaz-Mendez
Nov 12 '18 at 22:17
A comment in the answer you linked clarifies, do not use
/src/main/webapp
if you are packaging as as JAR, not strictly using JARs. You are packaging as WAR.– Edwin Diaz-Mendez
Nov 12 '18 at 22:17
@EdwinDiaz-Mendez OK but it says it will silently fail for other tools. If we wish to switch to maybe WebLogic or another servlet container, I would like to make the app as portable as possible without having it silently fail or require lots of code-rework. We are also working on automated deployments from Git so it would no longer be in a WAR/JAR format then (maybe). Basically I want to stick with best, most accepted practices, even if we can get away with it in our special niche circumstance.
– Chloe
Nov 13 '18 at 21:03
@EdwinDiaz-Mendez OK but it says it will silently fail for other tools. If we wish to switch to maybe WebLogic or another servlet container, I would like to make the app as portable as possible without having it silently fail or require lots of code-rework. We are also working on automated deployments from Git so it would no longer be in a WAR/JAR format then (maybe). Basically I want to stick with best, most accepted practices, even if we can get away with it in our special niche circumstance.
– Chloe
Nov 13 '18 at 21:03
add a comment |
0
active
oldest
votes
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%2f53270219%2feclipse-vs-spring-boot-gives-jsp-error-fragment-js-home-js-was-not-found-at%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
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%2f53270219%2feclipse-vs-spring-boot-gives-jsp-error-fragment-js-home-js-was-not-found-at%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
I changed it to
<script src="/js/home.js" type="text/javascript"></script>
for the time being.– Chloe
Nov 12 '18 at 21:39
A comment in the answer you linked clarifies, do not use
/src/main/webapp
if you are packaging as as JAR, not strictly using JARs. You are packaging as WAR.– Edwin Diaz-Mendez
Nov 12 '18 at 22:17
@EdwinDiaz-Mendez OK but it says it will silently fail for other tools. If we wish to switch to maybe WebLogic or another servlet container, I would like to make the app as portable as possible without having it silently fail or require lots of code-rework. We are also working on automated deployments from Git so it would no longer be in a WAR/JAR format then (maybe). Basically I want to stick with best, most accepted practices, even if we can get away with it in our special niche circumstance.
– Chloe
Nov 13 '18 at 21:03