Загрузка <script> по адресу не удалась

191
21 марта 2018, 06:45

Пытаюсь связать Angular 1.6.9 с Spring MVC Однако при деплое на Tomcat оно не хочет подгружать script, выдавая данную ошибку:

Загрузка <script> по адресу «http://localhost:8080/js/index.js» не удалась.

Папка js-файлов в tomcat:

C:\Program Files\apache-tomcat-8.5.28\webapps\page\WEB-INF\js

Имеется простая страница:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html ng-app="mainApp">
    <head>
        <meta charset="utf-8">
        <title>Spring MVC and AngularJS</title>
        <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js"></script>
        <script src="/js/index.js"></script>
    </head>
    <body>
        <div ng-controller="Hello">
            <p>This ID is {{type.id}}</p>
            <p>This name is {{type.name}}</p>           
        </div>
    </body>
</html>

к нему относится данный js-файл:

var mainApp = angular.module("mainApp", []);
mainApp.controller('Hello', function($scope, $http){
    $http.get("http://localhost:8080/page/main").
        then(function(response){
            $scope.type = response.data;
        });
});

Иерархия проекта:

Answer 1

В Java™ Servlet Specification version 3.1 написано:

A special directory exists within the application hierarchy named WEB-INF. This directory contains all things related to the application that aren’t in the document root of the application. The WEB-INF node is not part of the public document tree of the application. No file contained in the WEB-INF directory may be served directly to a client by the container. However, the contents of the WEB-INF directory are visible to servlet code using the getResource and getResourceAsStream method calls on the ServletContext, and may be exposed using the RequestDispatcher calls.

Не надо в WEB-INF складывать статику.

READ ALSO
Через каждые два символа вставлять /

Через каждые два символа вставлять /

Подскажите как написать выражениеПример 11/11/11

146
Как сделать запрос к chrome.storage не асинхронно?

Как сделать запрос к chrome.storage не асинхронно?

Пишу расширение для ХромаНа странице Options сохраняю некоторые параметры с помощью chrome

140
Проблема с indexOf()

Проблема с indexOf()

Возникла следующая проблема: код реагирует на ЛЮБОЕ значение, а должен только если там есть английские буквы и/или цифры

109
Наполнить переменную типа rowtype в oracle из php

Наполнить переменную типа rowtype в oracle из php

Всем привет) в общем ситуация) в oracle есть переменная типа rowtype, как мне ее наполнить данными полученными с формы, с помощью PHPСейчас я делаю...

191