From 1173ca57be66a17d8859358c8252f4873e52b868 Mon Sep 17 00:00:00 2001 From: qibaoguang Date: Tue, 10 Feb 2015 23:39:30 +0800 Subject: [PATCH] =?UTF-8?q?Update=2026.1.=20The=20=E2=80=98Spring=20Web=20?= =?UTF-8?q?MVC=20framework=E2=80=99.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../26.1. The ‘Spring Web MVC framework’.md | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/IV. Spring Boot features/26.1. The ‘Spring Web MVC framework’.md b/IV. Spring Boot features/26.1. The ‘Spring Web MVC framework’.md index e69de29..a3eb976 100644 --- a/IV. Spring Boot features/26.1. The ‘Spring Web MVC framework’.md +++ b/IV. Spring Boot features/26.1. The ‘Spring Web MVC framework’.md @@ -0,0 +1,28 @@ +### 26.1. Spring Web MVC框架 + +Spring Web MVC框架(通常简称为"Spring MVC")是一个富"模型,视图,控制器"的web框架。 +Spring MVC允许你创建特定的@Controller或@RestController beans来处理传入的HTTP请求。 +使用@RequestMapping注解可以将控制器中的方法映射到相应的HTTP请求。 + +示例: +```java +@RestController +@RequestMapping(value="/users") +public class MyRestController { + + @RequestMapping(value="/{user}", method=RequestMethod.GET) + public User getUser(@PathVariable Long user) { + // ... + } + + @RequestMapping(value="/{user}/customers", method=RequestMethod.GET) + List getUserCustomers(@PathVariable Long user) { + // ... + } + + @RequestMapping(value="/{user}", method=RequestMethod.DELETE) + public User deleteUser(@PathVariable Long user) { + // ... + } +} +```