Spring MVC and Angularjs Spring MVC and Angularjs angularjs angularjs

Spring MVC and Angularjs


As far as I can understand, your Front End technology is Angualar JS and your Back End technology is Spring MVC.

I'm a Front End developer and hence I can provide you the advice on the structure of your HTML, CSS, and Javascript.

Here are my recommendations:

  1. Mode Of Communication Between Front End and Back End: JSON (Should be strictly followed for MVC Pattern)

  2. File Location: All your Front End files should be in WEB-INF folder with this structure:

    • WEB-INF/Assets: All your JavaScript Files, JavaScript Libraries, Images, CSS etc. Should Be Places Here. You Can Open A Separate Folder Each Resource Type Inside Assets

    • WEB-INF/JSP: All Your JSPs should be placed here. As Angular's greatest strength is Single page Application, you can create one JSP per main page and place them here

    • WEB-INF/HTML: All the static resources that would be injected into the JSPs using <ng-view>or <ng-include> can be placed here

Hope this helps!


The easiest way to get going is to take all the files in the angular-seed/app directory and copy them into your src/main/webapp directory. After copying these files, you should be able to redeploy the app and have a running sample.

Most servlet containers will include index.html as a default welcome file. If yours doesn't, you can add that config in web.xml <welcome-file-list>.

The WEB-INF directory is for web resources that should not be exposed directly to the web. web.xml is a example of a file that should not be exposed to remote users. In this case, it's safe to expose all of the app's resources directly to the web; thus you don't need to place the resources under WEB-INF.


I recommend this structure for your project:

my-simple-app:    src        main            java                controller                    MySpringCtr.java                models                    Person.java                    House.java                    *.java        webapp            WEB-INF                resources                    css                        style.css                        *.css                    js                        angularCtr.js                        *.js                pages                    index.jsp                    *.jsp                mvc-dispatcher-servlet.xml                web.xml

I found a tutorial for beginners which explains step by step how to combine SpringMVC and AngularJS, you can find the tutorial and the complete code in this blog I hope it will be useful :)