cst1992 cst1992 - 1 year ago 47
AngularJS Question

AngularJS templates don't work with Spring

I have developed a REST application using Spring in NetBeans IDE.
Here is the relevant dir structure:
project structure

I want to integrate Angular functionality into it, but will prefer to keep it as a single app, rather than separate Angular and Spring apps.

The main

file should show the template
on the front page.

The Problem:

Adding HTML files to the
folder doesn't seem to work in the Angular application. If I try to access the
files through Angular, I get a 404 error, but I can open them directly.

Here's the controller in my Spring application for these two files:

public String index() {
return "index";

public String home() {
return "home";

I have written AngularJS code before by itself, and I didn't have any problems.

  • Am I mixing some things that I shouldn't?

  • Do I create all my AngularJS code in a separate folder, away from


A crude way to do this was to place the main index.html file in the src/main/resources/templates directory, and place all other resources required by the Angular app in src/main/resources/static/. To avoid confusion with the outside templates folder, I named the folder with the Angular templates as views.