Update 26.1. The ‘Spring Web MVC framework’.md

master
qibaoguang 2015-02-10 23:39:30 +08:00
parent f67f38877a
commit 1173ca57be
1 changed files with 28 additions and 0 deletions

View File

@ -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<Customer> getUserCustomers(@PathVariable Long user) {
// ...
}
@RequestMapping(value="/{user}", method=RequestMethod.DELETE)
public User deleteUser(@PathVariable Long user) {
// ...
}
}
```