Files
spring-framework/framework-docs/modules/ROOT/pages/web/webflux/controller.adoc
Sam Brannen 4fb70b671a Remove obsolete role attributes for tab groups in the reference manual
Since we now use asciidoctor-tabs instead of spring-asciidoctor-backends,
we no longer need the `role="primary"` and `role="secondary"` attributes
for tab groups.

Closes gh-33506
2024-09-08 17:20:10 +02:00

46 lines
1002 B
Plaintext

[[webflux-controller]]
= Annotated Controllers
[.small]#xref:web/webmvc/mvc-controller.adoc[See equivalent in the Servlet stack]#
Spring WebFlux provides an annotation-based programming model, where `@Controller` and
`@RestController` components use annotations to express request mappings, request input,
handle exceptions, and more. Annotated controllers have flexible method signatures and
do not have to extend base classes nor implement specific interfaces.
The following listing shows a basic example:
[tabs]
======
Java::
+
[source,java,indent=0,subs="verbatim,quotes"]
----
@RestController
public class HelloController {
@GetMapping("/hello")
public String handle() {
return "Hello WebFlux";
}
}
----
Kotlin::
+
[source,kotlin,indent=0,subs="verbatim,quotes"]
----
@RestController
class HelloController {
@GetMapping("/hello")
fun handle() = "Hello WebFlux"
}
----
======
In the preceding example, the method returns a `String` to be written to the response body.