From 579809402cbaf5dc9ffeb396b9dad810a48f1437 Mon Sep 17 00:00:00 2001 From: qibaoguang Date: Mon, 16 Mar 2015 00:22:22 +0800 Subject: [PATCH] Update 11.3.1. The @RestController and @RequestMapping annotations.md --- ...The @RestController and @RequestMapping annotations.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/II. Getting started/11.3.1. The @RestController and @RequestMapping annotations.md b/II. Getting started/11.3.1. The @RestController and @RequestMapping annotations.md index e69de29..32d8b0e 100644 --- a/II. Getting started/11.3.1. The @RestController and @RequestMapping annotations.md +++ b/II. Getting started/11.3.1. The @RestController and @RequestMapping annotations.md @@ -0,0 +1,8 @@ + +### 11.3.1. @RestController和@RequestMapping注解 + +我们的`Example`类上使用的第一个注解是`@RestController`。这被称为一个构造型(stereotype)注解。它为阅读代码的人们提供建议。对于Spring,该类扮演了一个特殊角色。在本示例中,我们的类是一个web `@Controller`,所以当处理进来的web请求时,Spring会询问它。 + +`@RequestMapping`注解提供路由信息。它告诉Spring任何来自"/"路径的HTTP请求都应该被映射到`home`方法。`@RestController`注解告诉Spring以字符串的形式渲染结果,并直接返回给调用者。 + +**注**:`@RestController`和`@RequestMapping`注解是Spring MVC注解(它们不是Spring Boot的特定部分)。具体查看Spring参考文档的[MVC章节](http://docs.spring.io/spring/docs/4.1.5.RELEASE/spring-framework-reference/htmlsingle#mvc)。