MVCS - 模型视图控制器服务 [英] MVCS - Model View Controller Service

查看:328
本文介绍了MVCS - 模型视图控制器服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直使用MVC很长一段时间,并听取了关于服务层(例如Java的web项目),我一直在想,如果这是一个实建筑格局给我无法找到很多关于它的信息。

I've been using MVC for a long time and heard about the "Service" layer (for example in Java web project) and I've been wondering if that is a real architectural pattern given I can't find a lot of information about it.

MVCS的想法是有控制器和模型之间的服务层,封装一切可以在控制器中的业务逻辑。这种方式,控制器就在那里转发和控制的执行。你可以调用多个控制器服务(例如,一个网站和一个Web服务),而无需复制code。

The idea of MVCS is to have a Service layer between the controller and the model, to encapsulate all the business logic that could be in the controller. That way, the controllers are just there to forward and control the execution. And you can call a Service in many controllers (for example, a website and a webservice), without duplicating code.

推荐答案

服务层可以PTED了很多办法核能研究所$ P $,但它通常,你有你的核心业务处理逻辑的,而坐在你的MVC架构之下,但你的数据访问架构之上。

Service layer can be inerpreted a lot of ways, but it's usually where you have your core business processing logic, and sits below your MVC architecture, but above your data access architecture.

例如你一个完整的系统层可能是这样的:

For example you layer of a complete system may look like this:


  1. 视图层:您的MVC框架和放大器;选择code

  2. 服务层:你的控制器将调用这一层的对象,以获取或更新型号,或其他请求

  3. 数据访问对象:这是抽象的,你的服务层将调用获取/更新需要的数据。这一层一般或者调用数据库或其他系统(例如:LDAP服务器,Web服务,或的NoSql型DB)

服务层然后将负责:


  • Retreiving并创建各种数据源(或数据访问对象)模型。

  • 更新跨越各种信息库/资源价值。

  • 执行应用程序特定的逻辑和操作等。

您在使用MVC模型可能会或可能不是来自你的服务。你可能想利用你的服务使您的结果并处理成一个模型,更具体到你的介质(如:网页)。

Your Model you use in your MVC may or may not come from your services. You may want to take the results your service gives you and manipulate them into a Model that's more specific to your medium (eg: a web page).

这篇关于MVCS - 模型视图控制器服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆