简体   繁体   中英

Spring MVC & Apache Tiles port to AngularJS/Backbone

I'm stuck with a mess of a web application. The previous developer started porting the Spring MVC/Apache Tiles application to Backbone, there wasn't a RESTful API to support the port however and it's stuck in this funky state where JSPs are rendering the HTML and some JS which then loads a Backbone View. About half the API has been ported to REST but the application is still far being a true SPA and even further from being done properly.

I've got a strong background in Angular and little with Backbone but next to nothing with Spring & Apache Tiles. The application either needs to go back to server side templating or be rewritten to truly become a SPA with proper organization/testing.

If I start (properly) porting to Angular or Backbone, is it possible for the two frameworks to work together (Spring / Angular or Backbone)? I've done a port like this in the past from Django to Angular on Google App Engine and it wasn't too bad but the application has significantly smaller. Has anyone done something similar to this, if so I've been unable to find anything on how to go about doing so or if I should even try.

Well, if you don't have a background in Spring & Tiles, it'll be difficult to learn & then port.

But if you're up for it :

1. Read about Spring (Dependency Injection & Configuration)
2. Read about Spring-MVC
3. Read about Tiles

Since, you already know about Django, you should be able to spot the similarities very soon. Once you become comfortable with Spring & Tiles, follow this approach :

1. Take a controller
2. Convert the JSP (which is returned by this controller) to a html template (used by Angular/Backbone)
3. Convert the model (data sent to the JSP) to JSON & start returning this JSON instead of the JSP
4. Create a route & test
5. Pick another controller

JSP is just a template & then model(data) is passed to create the actual html response, same as we do in case of Backbone (underscore template & then pass data to create the actual html).

This should be enough to start.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM