Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
966ee879
Commit
966ee879
authored
Apr 09, 2014
by
Dave Syer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
@Controller -> @RestController in docs
Fixes gh-652
parent
b8b883de
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
12 deletions
+9
-12
getting-started.adoc
spring-boot-docs/src/main/asciidoc/getting-started.adoc
+6
-8
spring-boot-cli.adoc
spring-boot-docs/src/main/asciidoc/spring-boot-cli.adoc
+3
-4
No files found.
spring-boot-docs/src/main/asciidoc/getting-started.adoc
View file @
966ee879
...
...
@@ -334,11 +334,10 @@ a file called `app.groovy`:
[source,groovy,indent=0,subs="verbatim,quotes,attributes"]
----
@Controller
@
Rest
Controller
class ThisWillActuallyRun {
@RequestMapping("/")
@ResponseBody
String home() {
return "Hello World!"
}
...
...
@@ -518,12 +517,11 @@ file named `src/main/java/Example.java`:
import org.springframework.stereotype.*;
import org.springframework.web.bind.annotation.*;
@Controller
@
Rest
Controller
@EnableAutoConfiguration
public class Example {
@RequestMapping("/")
@ResponseBody
String home() {
return "Hello World!";
}
...
...
@@ -541,18 +539,18 @@ important parts.
[[getting-started-first-application-annotations]]
==== The @
Controller, @RequestMapping and @ResponseBody
annotations
The first annotation on our `Example` class is `@Controller`. This is known as a
==== The @
RestController and @RequestMapping
annotations
The first annotation on our `Example` class is `@
Rest
Controller`. This is known as a
_stereotype_ annotation. It provides hints for people reading the code, and for Spring,
that the class plays a specific role. In this case, our class is a web `@Controller` so
Spring will consider it when handling incoming web requests.
The `@RequestMapping` annotation provides ``routing'' information. It is telling Spring
that any HTTP request with the path "`/`" should be mapped to the `home` method. The
additional `@ResponseBody
` annotation tells Spring to render the resulting string directly
`@RestController
` annotation tells Spring to render the resulting string directly
back to the caller.
TIP: The `@
Controller`, `@RequestMapping` and `@ResponseBody
` annotations are Spring MVC
TIP: The `@
RestController` and`@RequestMapping
` annotations are Spring MVC
annotations (they are not specific to Spring Boot). See the
<{spring-reference}/#mvc>[MVC section] in the Spring
Reference Documentation for more details.
...
...
spring-boot-docs/src/main/asciidoc/spring-boot-cli.adoc
View file @
966ee879
...
...
@@ -82,11 +82,10 @@ Here is an example ``hello world'' web application written in Groovy:
[source,groovy,indent=0,subs="verbatim,quotes,attributes"]
----
@Controller
@
Rest
Controller
class WebApplication {
@RequestMapping("/")
@ResponseBody
String home() {
return "Hello World!"
}
...
...
@@ -104,7 +103,7 @@ same way as Maven or Gradle would; but without requiring you to use a build tool
Spring Boot extends this technique further, and will attempt to deduce which libraries
to ``grab'' based on your code. For example, since the `WebApplication` code above uses
`@Controller` annotations, ``Tomcat'' and ``Spring MVC'' will be grabbed.
`@
Rest
Controller` annotations, ``Tomcat'' and ``Spring MVC'' will be grabbed.
The following items are used as ``grab hints'':
...
...
@@ -158,7 +157,7 @@ in the Spring Boot CLI source code to understand exactly how customizations are
==== Default import statements
To help reduce the size of your Groovy code, several `import` statements are
automatically included. Notice how the example above refers to `@Component`,
`@
Controller`, `@RequestMapping` and `@ResponseBody
` without needing to use
`@
RestController` and `@RequestMapping
` without needing to use
fully-qualified names or `import` statements.
TIP: Many Spring annotations will work without using `import` statements. Try running
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment