简体   繁体   中英

Why i am getting 404 error on js included in html?

I am building a webapp using Maven, Spring 4, Angularjs and Thymeleaf. I create some Thymeleaf template ( in directoty templates/fragments ). I have attached a screenshot of my eclipse web project. 在此处输入图片说明

The problem i am facing is about referencing libraries and css file, i am getting 404 not found on firebug.

HTML (index.html)

<!DOCTYPE html SYSTEM "http://www.thymeleaf.org/dtd/xhtml1-strict-thymeleaf-spring4-4.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
  <head>
    <script type="text/javascript" href="/js/lib/angular.js" th:src="@{/js/lib/angular.js}"></script>
    <script type="text/javascript" th:src="@{/js/lib/ui-bootstrap-tpls-0.11.0.js}"></script>
    <title>Jobly - login page</title>
  </head>
  <body>
    <div th:include="templates/fragments/header::header"></div>
    <h1>Hello on a second page!</h1>
    <p>Click <a th:href="@{/hello}">here</a> to go back.</p>
    <div th:include="templates/fragments/footer::footer"></div>
  </body>
</html>

Here is the snippet code of header template :

<link th:href="@{/css/bootstrap.min.css}" rel="stylesheet" media="screen"/>

<script type="text/javascript" th:src="@{/js/lib/jquery-1.11.1.min.js}"></script>
<script type="text/javascript" th:src="@{/js/lib/bootstrap.min.js}"></script>

Below the screenshot of 404 error 在此处输入图片说明

I've resolved my problem. It was a problem of specifing resources location and mapping in Spring configuration file. I add in app-servlet.xml

<mvc:resources mapping="/**" location="/"/>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM