AngularJS with Spring -mvc

I recently met AngularJS. I am a Java web developer. I want to use AngularJS along with the Spring-MVC framework. But first, I need a basic foundation (tutorial).

I know about the main stuff of AngularJS, but how to integrate it with Spring-MVC. Since most of the spring time he returns partial jsp (s), and we add them using jsp-include, while AngularJS expects JSON data most of the time.

+42
angularjs spring-mvc
Sep 01 '13 at 11:08
source share
3 answers

Two cases:

  • Your architecture is completely on the client side: in this case, the integration is very natural. Spring MVC provides your service as REST (JSON / XML), and your client application using AngularJS consumes your JSON. Here, the .war application (Spring MVC) must be deployed to a servlet container (e.g. Tomcat), and your client application can be deployed to the same server or to an HTTP server such as Nginx or Apache.

  • You want to save page generation on the server side and use only AngularJS for some DOM manipulations, so your code should be deployed in the same .war (inside the WEB-INF / folder).

Mixing the two approaches is not always a good idea. You can try Thymeleaf to stay on the server generation page and at the same time have templating, testability and clean View code.

+52
02 Sep '13 at 10:44
source share

Just install angular.js files as static files. There should not be anything private.

Use Spring MVC as a REST service provider instead of JSP / Velocity / Any other permissions for viewing templates.

You have sample projects on the following sites:

+35
Sep 01 '13 at 11:15
source share

If you like to learn by example, you can try to generate code using jhipster: https://jhipster.imtqy.com/

0
Jul 23 '15 at 8:23
source share



All Articles