English 中文(简体)
MVC - 如果意见允许与服务局直接互动,而不通过主计长。
原标题:MVC - Should the View be allowed to interact directly with the Services without going through Controller

我的架构就是这样:

View - Controller - Services

想把一种观点作为个人的详细一页。 控制器打电话

(Person) service.getPerson(1234)

并将人诉人视为显示。 个人通过RESTFul网络服务进行互动的方式。

其余服务的反应如下:

<person>
  <id>1234</id>
  <name>John Doe</name>
  <person-detail-uri>/person/1234/detail</person-detail-uri>
</person>

以上答复被描绘成一个称为“人”的一类人,他们看着这样的情况:

class Person{
    Long id;
    String name;
    String age;
    String address
}

可以通过使当事人通过该个人来制造完整的物体

/person/1234

然后通过细节

/person/1234/detail

认为这种观点需要显示个人细节。

问题:

备选案文A:如果主计长打电话给Person()和让PersonDetails()上班,以建立一个完整的个人案例

备选案文B:只有Person()并且让观点被人指名。 得到一定(可能通过各方面)的详细信息。

然而,在备选案文A中,我失去一些灵活性,这使我认为模式是一件好事,因为这样,鉴于错误的法典不能污染 ca,因而不会引起对业绩的关切。

最佳回答

没有任何“应当”,这只是取决于。 海事组织会冒风险让视层去做幻觉的初始化,因为它很容易意外地向许多问题开火而毫无意义。

此外,它使观点层相当明智,因为它现在控制数据初步化,而不是把控制器或模型中的数据单相隔。 我喜欢 views,但这可能带有偏见,而不是纯粹基于技术理由。

问题回答

暂无回答




相关问题
Getting sitemesh to work with struts2

I m trying to integrate sitemesh into my struts2 app, but i m finding that it s not making any difference and isn t showing any errors (or anything sitemesh related at all) in the logs. I ve started ...

Struts Action Validation

Hey People. I have been recently validating Struts 2 actions. In One of my action class, the save method to be precise must have two id s. That is an assessmenttype id and a course id. this is what is ...

struts2 action not calling properly

On default I want my struts2 app to forward to an action: <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"...

How to validate a select tag in struts 2 framework

I am a newbie into programming and i am currently employed as a junior programmer. I am currently having some problems validating the select tags in one of my forms. What i actually trying to do is to ...

Setting the default value in Struts2

I am setting the value(kind of default value) for a drop down select value from action class in a page(given below). When the page loads the value is beig displayed but the other elements of the ...

Localized exceptions (within a Struts2 app)

I am developing a Struts 2 application with support for multiple languages. If one of the domain objects needs to throw an exception, how can it do so in such a way that the error message is no ...

热门标签