我被一个困惑的网络应用程序困住了。之前的开发人员开始将 Spring MVC/Apache Tiles 应用程序移植到 Backbone,但是没有 RESTful API 来支持该移植,并且它陷入了这种奇怪的状态,其中 JSP 渲染 HTML 和一些 JS,然后加载 Backbone View 。大约一半的 API 已移植到 REST,但该应用程序距离真正的 SPA 还很远,距离正确完成还很远。
我在 Angular 方面有很强的背景,但对 Backbone 的了解很少,但对 Spring 和 Apache Tiles 几乎一无所知。应用程序要么需要返回到服务器端模板,要么需要重写以真正成为具有适当组织/测试的 SPA。
如果我开始(正确)移植到 Angular 或 Backbone,这两个框架是否可以一起工作(Spring/Angular 或 Backbone)?我过去曾在 Google App Engine 上做过类似的从 Django 到 Angular 的移植,效果还不错,但应用程序明显变小了。有没有人做过类似的事情,如果有的话,我一直找不到任何关于如何去做或我是否应该尝试的信息。
最佳答案
好吧,如果您没有 Spring 和 Tiles 背景,那么学习和移植将会很困难。
但是如果你愿意的话:
1. Read about Spring (Dependency Injection & Configuration)
2. Read about Spring-MVC
3. Read about Tiles
既然您已经了解 Django,您应该很快就能发现相似之处。一旦您熟悉了 Spring 和 Tiles,请遵循以下方法:
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 只是一个模板,然后传递模型(数据)来创建实际的 html 响应,就像我们在 Backbone 中所做的那样(下划线模板然后传递数据来创建实际的 html)。
这应该足以开始。
关于java - Spring MVC 和 Apache Tiles 移植到 AngularJS/Backbone,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26000195/