javascript MVC 或 Rest 或两者兼而有之

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4840245/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-25 15:03:58  来源:igfitidea点击:

MVC or Rest or Both

javajavascriptmodel-view-controllerrestarchitecture

提问by thecountofzero

I in the process of designing the server side of a web-based user interface that will be very JavaScript intensive.

我正在设计一个基于 Web 的用户界面的服务器端,这将是 JavaScript 密集型的。

I originally thought of going with an MVC solution, but now I am thinking I want to use a REST-based solution such as Jersey or Restlets.

我最初想使用 MVC 解决方案,但现在我想我想使用基于 REST 的解决方案,例如 Jersey 或 Restlets。

Is this often an one or the other type decision or can they be a combined solution?

这通常是一种或另一种类型的决定还是它们可以是组合解决方案?

Thanks, Mike

谢谢,迈克

回答by lbz

MVC is about how the inner side of your app works.

MVC 是关于你的应用程序的内部如何工作的。

REST is about how your app "talks" with other apps.

REST 是关于您的应用程序如何与其他应用程序“对话”。

You can combine them.

你可以组合它们。

A lot of modern frameworks actually are MVC based and make implementing REST web services easy: Ruby on Rails, Java Spring Framework with SpringMVC , Django, Backbone.js

许多现代框架实际上是基于 MVC 的,并且使实现 REST web 服务变得容易:Ruby on Rails、Java Spring Framework with SpringMVC、Django、Backbone.js

回答by hisdrewness

One of the best Java frameworks I've seen for building MVC webapps with the ability to support REST is SpringMVC. This blog postoutlines the REST capabilities in SpringMVC since version 3.0. I've developed REST services using SpringMVC and Jersey, and they are fairly comparable.

我见过的最好的 Java 框架之一是SpringMVC这篇博文概述了 SpringMVC 3.0 以来的 REST 功能。我已经使用 SpringMVC 和 Jersey 开发了 REST 服务,它们具有相当的可比性。

回答by ocodo

They are patterns / solutions to solve different problems.

它们是解决不同问题的模式/解决方案。

REST sanitises & simplifies addressing access to features of a web application, for users, client software, etc.

REST 清理并简化了对用户、客户端软件等 Web 应用程序功能的访问。

MVC provides a means to organise your application code, making it easier to maintain.

MVC 提供了一种组织应用程序代码的方法,使其更易于维护。

回答by ocodo

MVCis an architectural design pattern for the layers of your application.

MVC是应用程序层的架构设计模式。

The folder structure:

文件夹结构:

Models/YourClassModel.php
Views/Home/HomeView.php
Controllers/Controller.php
index.php

The application style RESTis the Representational State Transferof the application.

应用程序风格REST是应用程序的Representational State Transfer