---
title: "Spring基础知识"
author: "hongan"
date: "2009-01-04T19:59:13Z"
tags: ["AOP", "MVC", "Spring", "Web", "领域模型"]
slug: "spring"
draft: false
lastmod: "2009-07-14T12:43:46Z"
id: 309772
url: "https://hongan.iteye.com/blog/309772"
---

零、Spring MVC基础

领域模型：业务逻辑。

 

用户界面层：用户界面。

Web层：提供导航逻辑，处理请求参数、会话信息、HTTP响应代码。

服务层：提供粗粒度的服务接口，每个方法都应该是无状态的。

持久层：通过持久化机制处理领域模型的的实例。

 

一、依赖注入的方式：

Service Locator模式

```
public class CashRegisterImpl implements CashRegister{
  private PriceMatrix priceMatrix;
  public CashRegisterImpl(){
    priceMatrix=ServiceLocator.getPriceMatrix();
  }
  //...
}
```

Interface injection(implements interface methods).

Constructor injection.

Setter injection.

 

二、AOP:

![](/upload/picture/pic/25303/8f6f5f90-6612-3445-83a2-c94910e9b44a.jpg)

三、Spring Web MVC:

![](/upload/picture/pic/25309/32709453-903b-339c-9ac9-5d2975807d6f.gif)