Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring MVC and Angularjs

Currently I´m trying to learn Angular JS, but firstly I want to setup my environment with Spring mvc.

At the moment I only want to work with rest, but I have a doubt for what is the best way to place the resoucres in Spring MVC

My simple applicaction has this squeleton:

my-simple-app:
 src
   main
     java
     resources
   webapp
     resources
     WEB-INF

If I want to put the app folder from the angular-seed, what is the best place to put it?

I tried to put in src/webapp/resources/app but then I have to move the html files to WEB-INF?

How was your skeleton in your angular-js spring mvc applications?

What is the best way to do the redirect to the app/index.html? to the welcome file and then work only with angularjs $routeproviders?

Thanks!

like image 894
Gerard Ribas Avatar asked May 17 '13 20:05

Gerard Ribas


1 Answers

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!

like image 74
Abilash Avatar answered Sep 27 '22 22:09

Abilash