Architecture of a Spring MVC application with AJAX / JSON / REST
First, I developed a Java EE application with a Adobe Flex frontend and I used BlazeDS. So I had in the Java backend this structure开发者_运维知识库:
IServiceX -> ServiceImplX -> IDaoX -> DaoImplX
So the frontend called a service like "addUser(User u)". The service implementation calls the Dao interface which implements a Dao to a database and the User is added. The return value is the new User ID.
Now I want to use instead of Adobe Flex HTML5 with AJAX. So I found this example project: https://src.springframework.org/svn/spring-samples/mvc-ajax/
I have the problem how to integrate this into my existing architecture. In this case I have a domain object called Account.java and a controller AccountController.java: https://src.springframework.org/svn/spring-samples/mvc-ajax/trunk/src/main/java/org/springframework/samples/mvc/ajax/account/AccountController.java
Is it okay to create a Controller and this controller calls the already existing services? Or should I update/change my architecture (but I do not know how...)?
Thank you in advance & Best Regards.
You are right - simply create a XController
, annotated with @Controller
and inject your existing service there. Take a look at Spring MVC docs. Also check the ajax simplifications article for spring mvc 3.0
精彩评论