0

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)

Chloe
  • 25,162
  • 40
  • 190
  • 357
  • I changed it to `` 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 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

0 Answers0