我有一个用 JAVA 编写的应用程序(不是我写的),所有的路径对于标准路径应该是什么都非常不正常,并且该应用程序不会构建。我假设 . 我重新组织了路径,看起来像这样:
├── README.md
├── pom.xml
├── src
│ └── main
│ ├── java
│ │ └── com
│ │ └── appdomain
│ │ └── runtime
│ │ └── calculation
│ │ ├── Common
│ │ │ └── SendGridExample.java
│ │ ├── Data
│ │ │ ├── CommonMessages.java
│ │ │ ├── CommonUtils.java
│ │ │ └── WorkbookHelper.java
│ │ ├── Model
│ │ │ ├── CalculatorProperty.java
│ │ │ ├── FormHelper.java
│ │ │ └── ViewHelper.java
│ │ ├── Utility
│ │ │ ├── CurrencyUtility.java
│ │ │ ├── ImageUtils.java
│ │ │ └── AppUtility.java
│ │ └── controller
│ │ └── CalculatorController.java
│ ├── resources
│ │ ├── calculations.xlsx
│ │ ├── css
│ │ │ ├── CustomElement.css
│ │ │ ├── style-sheet.css
│ │ │ └── style1.css
│ │ ├── email_text
│ │ │ └── index.html
│ │ ├── fonts
│ │ │ └── …[font files]…
│ │ ├── images
│ │ │ └── [images].png
│ │ ├── js
│ │ │ ├── customInput.jquery.js
│ │ │ ├── input.js
│ │ │ └── output.js
│ │ └── lang
│ │ ├── messages_en.properties
│ │ └── messages_fn.properties
│ └── webapp
│ ├── WEB-INF
│ │ ├── classes
│ │ ├── jsp
│ │ │ ├── index.jsp
│ │ │ ├── template1.jsp
│ │ │ ├── template2.jsp
│ │ │ └── output.jsp
│ │ ├── log4j.properties
│ │ ├── springmvc-servlet.xml
│ │ └── web.xml
│ └── index.jsp
└── target
现在,当我使用 maven 构建它时,将 war 文件上传到 Tomcat Web 应用程序管理器,转到站点 (local.app:8080/myapp),站点模板看起来不错,并且加载了所有 3rd 方 CSS 和 JS(jquery、等...),但没有加载上述树中包含的任何 javascript 和 CSS。
目前 HTML 中的路径如下所示:classes/css/style-sheet.css 但我已经尝试了我能想到的所有路径,但仍然得到 404(例如 /myapp/WEB-INF/resources/css/style -sheet.css、/myapp/resources/css/style-sheet.css、css/style-sheet.css)。知道加载 CSS 和 JS 需要做什么吗?
是的。src/main/webapp
根据标准目录布局,您必须将静态 Web 资源(*.html、*.js、*.css、图像等)移动到。
目录src/main/resources
旨在包含要从 Java 读取的静态文件(如.properties
文件)。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句