Well I have an application with AngularJS that makes requests to the API gitHub
as an example to learn how to use AngularJS, but the problem is that when I put the page with all the dependencies in a Dynamic Web Project
Java (I do this because I need to use REST services defined with Jersey ), and I run it with Tomcat 8.0.36
, it gives me the following errors in the Chrome dev console (I try it in Chrome because in the browser Eclipse
I don't have a developer console to trace the errors).
The first time I try to log in localhost:8080/MissingDog
, this happens:
Then it shows this log when I keep trying to log in:
This is the log if I open the index.html directly from a folder, without putting it inside the Java Dynamic Web Project:
I leave you my directory tree of the Java project ( MascotaService.js
it is not implemented yet, it does nothing):
The error images show the cause of the problem, along with the image of your project structure. Your resources are inside the folder
WEB-INF
, which is not visible to browsers . Java application servers do not display the contents of this folder.To solve your problem, simply move the location files to outside of the
WEB-INF
. The structure of your project would be as follows:Just a little clarification, the files in the web-inf folder can be accessed, only web pages (jsp, xhtml, html), but to access the files inside this folder, you have to go through a controller, they will not be accessible to through a url, which is a good practice for security and follows the MVC pattern.
Cheers