Tomcat can not find the resources

1

Well I have an application with AngularJS that makes requests to the %% %% API 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% Java% (this is what I do because I need to use REST services defined with Jersey), and I run it with gitHub , I throw the following errors in the Chrome dev console (I try it in Chrome because in the Dynamic Web Project browser I do not have a developer console to trace the errors).

The first time I try to enter Tomcat 8.0.36 this happens: Then show this log when I keep trying to enter: 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 ( Eclipse is not implemented yet, it does not do anything):

    
asked by Augusto Herbel 18.09.2016 в 07:54
source

2 answers

2

The error images show the cause of the problem, along with the image of the structure of your project. Your resources are inside the WEB-INF folder, which is not visible in browsers . Application servers in Java do not show the contents of this folder.

To solve your problem, simply move the location files to outside the WEB-INF folder. The structure of your project would be as follows:

WebContent
- META-INF
- resources (aquí van tus recursos JS, CSS, etc)
  - css
  - fonts
  - images
  - js
  - lib
  - (otras carpetas...)
- WEB-INF
  + web.xml
  - (otros archivos y carpetas para la configuración de tu proyecto como web.xml)
    
answered by 19.09.2016 / 16:25
source
1

Just a little clarification, the files of the web-inf folder if they can be accessed, only web pages (jsp, xhtml, html), but to access the files inside this folder, you have to go through a controller, not will be accessible through a url, which is a good practice for safety and follows the pattern MVC.

Greetings

    
answered by 20.09.2016 в 01:11